gnumeric r16798 - in trunk: . src/dialogs src/tools



Author: guelzow
Date: Tue Sep 16 05:51:15 2008
New Revision: 16798
URL: http://svn.gnome.org/viewvc/gnumeric?rev=16798&view=rev

Log:
2008-09-14  Andreas J. Guelzow <aguelzow pyrshep ca>

	* histogram.glade: redesign
	* dialog-analysis-tools.c (bin_type_group): new
	(histogram_tool_ok_clicked_cb): adjust to new glade file
	(dialog_histogram_tool): ditto

2008-09-14  Andreas J. Guelzow <aguelzow pyrshep ca>

	* analysis-histogram.c: completely rewritten from scratch
	* analysis-histogram.h: completely rewritten from scratch
	* analysis-tools.h (new_data_set_list): made statis
	(destroy_data_set_list): made static
	(gnm_check_input_range_list_homogeneity): made static
	(make_cellref): made non-static
	* analysis-tools.c (new_data_set_list): made statis
	(destroy_data_set_list): made static
	(gnm_check_input_range_list_homogeneity): made static
	(make_cellref): made non-static




Modified:
   trunk/NEWS
   trunk/src/dialogs/ChangeLog
   trunk/src/dialogs/dialog-analysis-tools.c
   trunk/src/dialogs/histogram.glade
   trunk/src/tools/ChangeLog
   trunk/src/tools/analysis-histogram.c
   trunk/src/tools/analysis-histogram.h
   trunk/src/tools/analysis-tools.c
   trunk/src/tools/analysis-tools.h

Modified: trunk/NEWS
==============================================================================
--- trunk/NEWS	(original)
+++ trunk/NEWS	Tue Sep 16 05:51:15 2008
@@ -11,6 +11,7 @@
 	* Don't force text export of empty sheets [#521726]
 	* By default cells with hyperlinks should not be empty [#152617]
 	* Fix command names for hyperlink additions.
+	* Improve histogram tool [#385458]
 
 Jean:
 	* Fix printing of rotated text. [#539734]

Modified: trunk/src/dialogs/dialog-analysis-tools.c
==============================================================================
--- trunk/src/dialogs/dialog-analysis-tools.c	(original)
+++ trunk/src/dialogs/dialog-analysis-tools.c	Tue Sep 16 05:51:15 2008
@@ -91,12 +91,25 @@
 	GenericToolState base;
 	GtkWidget *predetermined_button;
 	GtkWidget *calculated_button;
-	GtkWidget *bin_labels_button;
 	GtkEntry  *n_entry;
 	GtkEntry  *max_entry;
 	GtkEntry  *min_entry;
 } HistogramToolState;
 
+static char const * const bin_type_group[] = {
+	"bintype_no_inf_lower",
+	"bintype_no_inf_upper",
+	"bintype_p_inf_lower",
+	"bintype_p_inf_upper",
+	"bintype_m_inf_lower",
+	"bintype_m_inf_upper",
+	"bintype_pm_inf_lower",
+	"bintype_pm_inf_upper",
+	NULL
+};
+
+
+
 typedef struct {
 	GenericToolState base;
 	GtkWidget *summary_stats_button;
@@ -2483,17 +2496,17 @@
 	data = g_new0 (analysis_tools_data_histogram_t, 1);
 	dao  = parse_output ((GenericToolState *)state, NULL);
 
-	data->input = gnm_expr_entry_parse_as_list (
+	data->base.input = gnm_expr_entry_parse_as_list (
 		GNM_EXPR_ENTRY (state->base.input_entry), state->base.sheet);
-	data->group_by = gnumeric_glade_group_value (state->base.gui, grouped_by_group);
+	data->base.group_by = gnumeric_glade_group_value (state->base.gui, grouped_by_group);
 
-	if (gtk_toggle_button_get_active (
-		GTK_TOGGLE_BUTTON (state->predetermined_button))) {
+	data->predetermined = gtk_toggle_button_get_active (
+		GTK_TOGGLE_BUTTON (state->predetermined_button));
+	if (data->predetermined) {
 		w = glade_xml_get_widget (state->base.gui, "labels_2_button");
-		data->bin_labels = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (w));
-		data->bin = g_slist_prepend (NULL, gnm_expr_entry_parse_as_value
-					     (GNM_EXPR_ENTRY (state->base.input_entry_2),
-					      state->base.sheet));
+		data->bin = gnm_expr_entry_parse_as_value
+			(GNM_EXPR_ENTRY (state->base.input_entry_2),
+			 state->base.sheet);
 	} else {
 		entry_to_int(state->n_entry, &data->n,TRUE);
 		data->max_given = (0 == entry_to_float (state->max_entry,
@@ -2503,23 +2516,21 @@
 		data->bin = NULL;
 	}
 
+	data->bin_type = gnumeric_glade_group_value (state->base.gui, bin_type_group);
+
 	w = glade_xml_get_widget (state->base.gui, "labels_button");
-	data->labels = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (w));
-	w = glade_xml_get_widget (state->base.gui, "pareto-button");
-	data->pareto = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (w));
+	data->base.labels = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (w));
 	w = glade_xml_get_widget (state->base.gui, "percentage-button");
 	data->percentage = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (w));
 	w = glade_xml_get_widget (state->base.gui, "cum-button");
 	data->cumulative = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (w));
-	w = glade_xml_get_widget (state->base.gui, "chart-button");
-	data->chart = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (w));
+/* 	w = glade_xml_get_widget (state->base.gui, "chart-button"); */
+/* 	data->chart = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (w)); */
 
 	if (!cmd_analysis_tool (WORKBOOK_CONTROL (state->base.wbcg), state->base.sheet,
 			       dao, data, analysis_tool_histogram_engine))
 		gtk_widget_destroy (state->base.dialog);
 
-/*				_("Each row of the bin range should contain one numeric value\n" */
-/*				  "(ignoring the label if applicable).")); */
 	return;
 }
 
@@ -2611,9 +2622,6 @@
 	state->calculated_button = GTK_WIDGET (glade_xml_get_widget
 					       (state->base.gui,
 						"calculated_button"));
-	state->bin_labels_button = GTK_WIDGET (glade_xml_get_widget
-					       (state->base.gui,
-						"labels_2_button"));
 	state->n_entry = GTK_ENTRY(glade_xml_get_widget (state->base.gui,
 							  "n_entry"));
 	state->max_entry = GTK_ENTRY(glade_xml_get_widget (state->base.gui,
@@ -2644,11 +2652,8 @@
 				  GNM_EXPR_ENTRY (state->base.input_entry_2))),
 		"focus-in-event",
 		G_CALLBACK (histogram_tool_set_predetermined), state);
-	g_signal_connect (G_OBJECT (state->bin_labels_button),
-		"toggled",
-		G_CALLBACK (histogram_tool_set_predetermined_on_toggle), state);
 
-	gnm_dao_set_put (GNM_DAO (state->base.gdao), FALSE, FALSE);
+	gnm_dao_set_put (GNM_DAO (state->base.gdao), TRUE, TRUE);
 	histogram_tool_update_sensitivity_cb (NULL, state);
 	tool_load_selection ((GenericToolState *)state, TRUE);
 

Modified: trunk/src/dialogs/histogram.glade
==============================================================================
--- trunk/src/dialogs/histogram.glade	(original)
+++ trunk/src/dialogs/histogram.glade	Tue Sep 16 05:51:15 2008
@@ -1,734 +1,716 @@
-<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
-<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd";>
-
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
+<!--*- mode: xml -*-->
 <glade-interface>
-
-<widget class="GtkDialog" id="Histogram">
-  <property name="border_width">6</property>
-  <property name="title" translatable="yes">Histogram</property>
-  <property name="type">GTK_WINDOW_TOPLEVEL</property>
-  <property name="window_position">GTK_WIN_POS_NONE</property>
-  <property name="modal">False</property>
-  <property name="resizable">True</property>
-  <property name="destroy_with_parent">False</property>
-  <property name="has_separator">False</property>
-
-  <child internal-child="vbox">
-    <widget class="GtkVBox" id="vbox1">
-      <property name="visible">True</property>
-      <property name="homogeneous">False</property>
-      <property name="spacing">6</property>
-
-      <child internal-child="action_area">
-	<widget class="GtkHButtonBox" id="hbuttonbox1">
-	  <property name="visible">True</property>
-	  <property name="layout_style">GTK_BUTTONBOX_END</property>
-
-	  <child>
-	    <widget class="GtkButton" id="helpbutton">
-	      <property name="visible">True</property>
-	      <property name="can_default">True</property>
-	      <property name="can_focus">True</property>
-	      <property name="label">gtk-help</property>
-	      <property name="use_stock">True</property>
-	      <property name="relief">GTK_RELIEF_NORMAL</property>
-	      <property name="response_id">0</property>
-	    </widget>
-	  </child>
-
-	  <child>
-	    <widget class="GtkButton" id="cancelbutton">
-	      <property name="visible">True</property>
-	      <property name="can_default">True</property>
-	      <property name="can_focus">True</property>
-	      <property name="label">gtk-cancel</property>
-	      <property name="use_stock">True</property>
-	      <property name="relief">GTK_RELIEF_NORMAL</property>
-	      <property name="response_id">0</property>
-	    </widget>
-	  </child>
-
-	  <child>
-	    <widget class="GtkButton" id="okbutton">
-	      <property name="visible">True</property>
-	      <property name="can_default">True</property>
-	      <property name="has_default">True</property>
-	      <property name="can_focus">True</property>
-	      <property name="label">gtk-ok</property>
-	      <property name="use_stock">True</property>
-	      <property name="relief">GTK_RELIEF_NORMAL</property>
-	      <property name="response_id">0</property>
-	    </widget>
-	  </child>
-	</widget>
-	<packing>
-	  <property name="padding">0</property>
-	  <property name="expand">False</property>
-	  <property name="fill">True</property>
-	  <property name="pack_type">GTK_PACK_END</property>
-	</packing>
-      </child>
-
-      <child>
-	<widget class="GtkNotebook" id="notebook1">
-	  <property name="border_width">5</property>
-	  <property name="visible">True</property>
-	  <property name="can_focus">True</property>
-	  <property name="show_tabs">True</property>
-	  <property name="show_border">True</property>
-	  <property name="tab_pos">GTK_POS_TOP</property>
-	  <property name="scrollable">False</property>
-	  <property name="enable_popup">False</property>
-
-	  <child>
-	    <widget class="GtkTable" id="input-table">
-	      <property name="border_width">12</property>
-	      <property name="visible">True</property>
-	      <property name="n_rows">3</property>
-	      <property name="n_columns">2</property>
-	      <property name="homogeneous">False</property>
-	      <property name="row_spacing">6</property>
-	      <property name="column_spacing">12</property>
-
-	      <child>
-		<widget class="GtkLabel" id="var1-label">
-		  <property name="visible">True</property>
-		  <property name="label" translatable="yes">Input _range:</property>
-		  <property name="use_underline">True</property>
-		  <property name="use_markup">False</property>
-		  <property name="justify">GTK_JUSTIFY_RIGHT</property>
-		  <property name="wrap">False</property>
-		  <property name="selectable">False</property>
-		  <property name="xalign">0</property>
-		  <property name="yalign">0.5</property>
-		  <property name="xpad">5</property>
-		  <property name="ypad">0</property>
-		</widget>
-		<packing>
-		  <property name="left_attach">0</property>
-		  <property name="right_attach">1</property>
-		  <property name="top_attach">0</property>
-		  <property name="bottom_attach">1</property>
-		  <property name="x_options">fill</property>
-		  <property name="y_options"></property>
-		</packing>
-	      </child>
-
-	      <child>
-		<widget class="GtkLabel" id="label1">
-		  <property name="visible">True</property>
-		  <property name="label" translatable="yes">Grouped by:</property>
-		  <property name="use_underline">False</property>
-		  <property name="use_markup">False</property>
-		  <property name="justify">GTK_JUSTIFY_CENTER</property>
-		  <property name="wrap">False</property>
-		  <property name="selectable">False</property>
-		  <property name="xalign">0</property>
-		  <property name="yalign">0.5</property>
-		  <property name="xpad">5</property>
-		  <property name="ypad">0</property>
-		</widget>
-		<packing>
-		  <property name="left_attach">0</property>
-		  <property name="right_attach">1</property>
-		  <property name="top_attach">1</property>
-		  <property name="bottom_attach">2</property>
-		  <property name="x_options">fill</property>
-		  <property name="y_options"></property>
-		</packing>
-	      </child>
-
-	      <child>
-		<widget class="GtkHBox" id="hbox1">
-		  <property name="visible">True</property>
-		  <property name="homogeneous">True</property>
-		  <property name="spacing">12</property>
-
-		  <child>
-		    <widget class="GtkRadioButton" id="grouped_by_col">
-		      <property name="visible">True</property>
-		      <property name="can_focus">True</property>
-		      <property name="label" translatable="yes">_Columns</property>
-		      <property name="use_underline">True</property>
-		      <property name="relief">GTK_RELIEF_NORMAL</property>
-		      <property name="active">False</property>
-		      <property name="inconsistent">False</property>
-		      <property name="draw_indicator">True</property>
-		    </widget>
-		    <packing>
-		      <property name="padding">0</property>
-		      <property name="expand">True</property>
-		      <property name="fill">True</property>
-		    </packing>
-		  </child>
-
-		  <child>
-		    <widget class="GtkRadioButton" id="grouped_by_row">
-		      <property name="visible">True</property>
-		      <property name="can_focus">True</property>
-		      <property name="label" translatable="yes">_Rows</property>
-		      <property name="use_underline">True</property>
-		      <property name="relief">GTK_RELIEF_NORMAL</property>
-		      <property name="active">False</property>
-		      <property name="inconsistent">False</property>
-		      <property name="draw_indicator">True</property>
-		      <property name="group">grouped_by_col</property>
-		    </widget>
-		    <packing>
-		      <property name="padding">0</property>
-		      <property name="expand">True</property>
-		      <property name="fill">True</property>
-		    </packing>
-		  </child>
-
-		  <child>
-		    <widget class="GtkRadioButton" id="grouped_by_area">
-		      <property name="visible">True</property>
-		      <property name="can_focus">True</property>
-		      <property name="label" translatable="yes">_Areas</property>
-		      <property name="use_underline">True</property>
-		      <property name="relief">GTK_RELIEF_NORMAL</property>
-		      <property name="active">True</property>
-		      <property name="inconsistent">False</property>
-		      <property name="draw_indicator">True</property>
-		      <property name="group">grouped_by_col</property>
-		    </widget>
-		    <packing>
-		      <property name="padding">0</property>
-		      <property name="expand">True</property>
-		      <property name="fill">True</property>
-		    </packing>
-		  </child>
-		</widget>
-		<packing>
-		  <property name="left_attach">1</property>
-		  <property name="right_attach">2</property>
-		  <property name="top_attach">1</property>
-		  <property name="bottom_attach">2</property>
-		  <property name="y_options">fill</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="relief">GTK_RELIEF_NORMAL</property>
-		  <property name="active">False</property>
-		  <property name="inconsistent">False</property>
-		  <property name="draw_indicator">True</property>
-		</widget>
-		<packing>
-		  <property name="left_attach">0</property>
-		  <property name="right_attach">2</property>
-		  <property name="top_attach">2</property>
-		  <property name="bottom_attach">3</property>
-		  <property name="x_options">fill</property>
-		  <property name="y_options"></property>
-		</packing>
-	      </child>
-	    </widget>
-	    <packing>
-	      <property name="tab_expand">False</property>
-	      <property name="tab_fill">True</property>
-	    </packing>
-	  </child>
-
-	  <child>
-	    <widget class="GtkLabel" id="label2">
-	      <property name="visible">True</property>
-	      <property name="label" translatable="yes">_Input</property>
-	      <property name="use_underline">True</property>
-	      <property name="use_markup">False</property>
-	      <property name="justify">GTK_JUSTIFY_CENTER</property>
-	      <property name="wrap">False</property>
-	      <property name="selectable">False</property>
-	      <property name="xalign">0.5</property>
-	      <property name="yalign">0.5</property>
-	      <property name="xpad">0</property>
-	      <property name="ypad">0</property>
-	    </widget>
-	    <packing>
-	      <property name="type">tab</property>
-	    </packing>
-	  </child>
-
-	  <child>
-	    <widget class="GtkVBox" id="vbox4">
-	      <property name="border_width">12</property>
-	      <property name="visible">True</property>
-	      <property name="homogeneous">False</property>
-	      <property name="spacing">0</property>
-
-	      <child>
-		<widget class="GtkTable" id="bin_table">
-		  <property name="visible">True</property>
-		  <property name="n_rows">3</property>
-		  <property name="n_columns">2</property>
-		  <property name="homogeneous">False</property>
-		  <property name="row_spacing">0</property>
-		  <property name="column_spacing">0</property>
-
-		  <child>
-		    <widget class="GtkLabel" id="var2-label">
-		      <property name="visible">True</property>
-		      <property name="label" translatable="yes">Bin _range:</property>
-		      <property name="use_underline">True</property>
-		      <property name="use_markup">False</property>
-		      <property name="justify">GTK_JUSTIFY_RIGHT</property>
-		      <property name="wrap">False</property>
-		      <property name="selectable">False</property>
-		      <property name="xalign">0</property>
-		      <property name="yalign">0.5</property>
-		      <property name="xpad">5</property>
-		      <property name="ypad">0</property>
-		    </widget>
-		    <packing>
-		      <property name="left_attach">0</property>
-		      <property name="right_attach">1</property>
-		      <property name="top_attach">1</property>
-		      <property name="bottom_attach">2</property>
-		      <property name="x_options">fill</property>
-		      <property name="y_options"></property>
-		    </packing>
-		  </child>
-
-		  <child>
-		    <widget class="GtkCheckButton" id="labels_2_button">
-		      <property name="visible">True</property>
-		      <property name="can_focus">True</property>
-		      <property name="label" translatable="yes">Bin _labels</property>
-		      <property name="use_underline">True</property>
-		      <property name="relief">GTK_RELIEF_NORMAL</property>
-		      <property name="active">False</property>
-		      <property name="inconsistent">False</property>
-		      <property name="draw_indicator">True</property>
-		    </widget>
-		    <packing>
-		      <property name="left_attach">0</property>
-		      <property name="right_attach">2</property>
-		      <property name="top_attach">2</property>
-		      <property name="bottom_attach">3</property>
-		      <property name="y_options"></property>
-		    </packing>
-		  </child>
-
-		  <child>
-		    <widget class="GtkRadioButton" id="pre_determined_button">
-		      <property name="visible">True</property>
-		      <property name="can_focus">True</property>
-		      <property name="label" translatable="yes">_Predetermined bins</property>
-		      <property name="use_underline">True</property>
-		      <property name="relief">GTK_RELIEF_NORMAL</property>
-		      <property name="active">False</property>
-		      <property name="inconsistent">False</property>
-		      <property name="draw_indicator">True</property>
-		    </widget>
-		    <packing>
-		      <property name="left_attach">0</property>
-		      <property name="right_attach">2</property>
-		      <property name="top_attach">0</property>
-		      <property name="bottom_attach">1</property>
-		      <property name="x_options">fill</property>
-		      <property name="y_options"></property>
-		    </packing>
-		  </child>
-		</widget>
-		<packing>
-		  <property name="padding">0</property>
-		  <property name="expand">True</property>
-		  <property name="fill">True</property>
-		</packing>
-	      </child>
-
-	      <child>
-		<widget class="GtkHSeparator" id="hseparator2">
-		  <property name="visible">True</property>
-		</widget>
-		<packing>
-		  <property name="padding">0</property>
-		  <property name="expand">True</property>
-		  <property name="fill">True</property>
-		</packing>
-	      </child>
-
-	      <child>
-		<widget class="GtkTable" id="table2">
-		  <property name="visible">True</property>
-		  <property name="n_rows">4</property>
-		  <property name="n_columns">2</property>
-		  <property name="homogeneous">False</property>
-		  <property name="row_spacing">0</property>
-		  <property name="column_spacing">0</property>
-
-		  <child>
-		    <widget class="GtkRadioButton" id="calculated_button">
-		      <property name="visible">True</property>
-		      <property name="can_focus">True</property>
-		      <property name="label" translatable="yes">_Calculated bins</property>
-		      <property name="use_underline">True</property>
-		      <property name="relief">GTK_RELIEF_NORMAL</property>
-		      <property name="active">False</property>
-		      <property name="inconsistent">False</property>
-		      <property name="draw_indicator">True</property>
-		      <property name="group">pre_determined_button</property>
-		    </widget>
-		    <packing>
-		      <property name="left_attach">0</property>
-		      <property name="right_attach">2</property>
-		      <property name="top_attach">0</property>
-		      <property name="bottom_attach">1</property>
-		      <property name="y_options"></property>
-		    </packing>
-		  </child>
-
-		  <child>
-		    <widget class="GtkEntry" id="max_entry">
-		      <property name="visible">True</property>
-		      <property name="can_focus">True</property>
-		      <property name="editable">True</property>
-		      <property name="visibility">True</property>
-		      <property name="max_length">0</property>
-		      <property name="text" translatable="yes"></property>
-		      <property name="has_frame">True</property>
-		      <property name="invisible_char" translatable="yes">*</property>
-		      <property name="activates_default">False</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="y_padding">2</property>
-		      <property name="y_options"></property>
-		    </packing>
-		  </child>
-
-		  <child>
-		    <widget class="GtkEntry" id="n_entry">
-		      <property name="visible">True</property>
-		      <property name="can_focus">True</property>
-		      <property name="editable">True</property>
-		      <property name="visibility">True</property>
-		      <property name="max_length">0</property>
-		      <property name="text" translatable="yes"></property>
-		      <property name="has_frame">True</property>
-		      <property name="invisible_char" translatable="yes">*</property>
-		      <property name="activates_default">False</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="y_padding">2</property>
-		      <property name="y_options"></property>
-		    </packing>
-		  </child>
-
-		  <child>
-		    <widget class="GtkLabel" id="label7">
-		      <property name="visible">True</property>
-		      <property name="label" translatable="yes">Ma_x:</property>
-		      <property name="use_underline">True</property>
-		      <property name="use_markup">False</property>
-		      <property name="justify">GTK_JUSTIFY_LEFT</property>
-		      <property name="wrap">False</property>
-		      <property name="selectable">False</property>
-		      <property name="xalign">0</property>
-		      <property name="yalign">0.5</property>
-		      <property name="xpad">0</property>
-		      <property name="ypad">0</property>
-		      <property name="mnemonic_widget">max_entry</property>
-		    </widget>
-		    <packing>
-		      <property name="left_attach">0</property>
-		      <property name="right_attach">1</property>
-		      <property name="top_attach">2</property>
-		      <property name="bottom_attach">3</property>
-		      <property name="x_padding">5</property>
-		      <property name="x_options">fill</property>
-		      <property name="y_options"></property>
-		    </packing>
-		  </child>
-
-		  <child>
-		    <widget class="GtkLabel" id="label9">
-		      <property name="visible">True</property>
-		      <property name="label" translatable="yes">_N:</property>
-		      <property name="use_underline">True</property>
-		      <property name="use_markup">False</property>
-		      <property name="justify">GTK_JUSTIFY_LEFT</property>
-		      <property name="wrap">False</property>
-		      <property name="selectable">False</property>
-		      <property name="xalign">0</property>
-		      <property name="yalign">0.5</property>
-		      <property name="xpad">0</property>
-		      <property name="ypad">0</property>
-		      <property name="mnemonic_widget">n_entry</property>
-		    </widget>
-		    <packing>
-		      <property name="left_attach">0</property>
-		      <property name="right_attach">1</property>
-		      <property name="top_attach">3</property>
-		      <property name="bottom_attach">4</property>
-		      <property name="x_padding">5</property>
-		      <property name="x_options">fill</property>
-		      <property name="y_options"></property>
-		    </packing>
-		  </child>
-
-		  <child>
-		    <widget class="GtkLabel" id="label8">
-		      <property name="visible">True</property>
-		      <property name="label" translatable="yes">M_in:</property>
-		      <property name="use_underline">True</property>
-		      <property name="use_markup">False</property>
-		      <property name="justify">GTK_JUSTIFY_LEFT</property>
-		      <property name="wrap">False</property>
-		      <property name="selectable">False</property>
-		      <property name="xalign">0</property>
-		      <property name="yalign">0.5</property>
-		      <property name="xpad">0</property>
-		      <property name="ypad">0</property>
-		      <property name="mnemonic_widget">min_entry</property>
-		    </widget>
-		    <packing>
-		      <property name="left_attach">0</property>
-		      <property name="right_attach">1</property>
-		      <property name="top_attach">1</property>
-		      <property name="bottom_attach">2</property>
-		      <property name="x_padding">5</property>
-		      <property name="x_options">fill</property>
-		      <property name="y_options"></property>
-		    </packing>
-		  </child>
-
-		  <child>
-		    <widget class="GtkEntry" id="min_entry">
-		      <property name="visible">True</property>
-		      <property name="can_focus">True</property>
-		      <property name="editable">True</property>
-		      <property name="visibility">True</property>
-		      <property name="max_length">0</property>
-		      <property name="text" translatable="yes"></property>
-		      <property name="has_frame">True</property>
-		      <property name="invisible_char" translatable="yes">*</property>
-		      <property name="activates_default">False</property>
-		    </widget>
-		    <packing>
-		      <property name="left_attach">1</property>
-		      <property name="right_attach">2</property>
-		      <property name="top_attach">1</property>
-		      <property name="bottom_attach">2</property>
-		      <property name="y_padding">2</property>
-		      <property name="y_options"></property>
-		    </packing>
-		  </child>
-		</widget>
-		<packing>
-		  <property name="padding">5</property>
-		  <property name="expand">True</property>
-		  <property name="fill">True</property>
-		</packing>
-	      </child>
-	    </widget>
-	    <packing>
-	      <property name="tab_expand">False</property>
-	      <property name="tab_fill">True</property>
-	    </packing>
-	  </child>
-
-	  <child>
-	    <widget class="GtkLabel" id="label3">
-	      <property name="visible">True</property>
-	      <property name="label" translatable="yes">_Bins</property>
-	      <property name="use_underline">True</property>
-	      <property name="use_markup">False</property>
-	      <property name="justify">GTK_JUSTIFY_CENTER</property>
-	      <property name="wrap">False</property>
-	      <property name="selectable">False</property>
-	      <property name="xalign">0.5</property>
-	      <property name="yalign">0.5</property>
-	      <property name="xpad">0</property>
-	      <property name="ypad">0</property>
-	    </widget>
-	    <packing>
-	      <property name="type">tab</property>
-	    </packing>
-	  </child>
-
-	  <child>
-	    <widget class="GtkVBox" id="vbox3">
-	      <property name="border_width">12</property>
-	      <property name="visible">True</property>
-	      <property name="homogeneous">False</property>
-	      <property name="spacing">6</property>
-
-	      <child>
-		<widget class="GtkCheckButton" id="pareto-button">
-		  <property name="visible">True</property>
-		  <property name="can_focus">True</property>
-		  <property name="label" translatable="yes">Pareto (_sorted)</property>
-		  <property name="use_underline">True</property>
-		  <property name="relief">GTK_RELIEF_NORMAL</property>
-		  <property name="active">False</property>
-		  <property name="inconsistent">False</property>
-		  <property name="draw_indicator">True</property>
-		</widget>
-		<packing>
-		  <property name="padding">0</property>
-		  <property name="expand">False</property>
-		  <property name="fill">False</property>
-		</packing>
-	      </child>
-
-	      <child>
-		<widget class="GtkCheckButton" id="percentage-button">
-		  <property name="visible">True</property>
-		  <property name="can_focus">True</property>
-		  <property name="label" translatable="yes">_Percentages</property>
-		  <property name="use_underline">True</property>
-		  <property name="relief">GTK_RELIEF_NORMAL</property>
-		  <property name="active">False</property>
-		  <property name="inconsistent">False</property>
-		  <property name="draw_indicator">True</property>
-		</widget>
-		<packing>
-		  <property name="padding">0</property>
-		  <property name="expand">False</property>
-		  <property name="fill">False</property>
-		</packing>
-	      </child>
-
-	      <child>
-		<widget class="GtkCheckButton" id="cum-button">
-		  <property name="visible">True</property>
-		  <property name="can_focus">True</property>
-		  <property name="label" translatable="yes">C_umulative percentages</property>
-		  <property name="use_underline">True</property>
-		  <property name="relief">GTK_RELIEF_NORMAL</property>
-		  <property name="active">False</property>
-		  <property name="inconsistent">False</property>
-		  <property name="draw_indicator">True</property>
-		</widget>
-		<packing>
-		  <property name="padding">0</property>
-		  <property name="expand">False</property>
-		  <property name="fill">False</property>
-		</packing>
-	      </child>
-
-	      <child>
-		<widget class="GtkCheckButton" id="chart-button">
-		  <property name="visible">True</property>
-		  <property name="sensitive">False</property>
-		  <property name="can_focus">True</property>
-		  <property name="label" translatable="yes">_Chart output</property>
-		  <property name="use_underline">True</property>
-		  <property name="relief">GTK_RELIEF_NORMAL</property>
-		  <property name="active">False</property>
-		  <property name="inconsistent">False</property>
-		  <property name="draw_indicator">True</property>
-		</widget>
-		<packing>
-		  <property name="padding">0</property>
-		  <property name="expand">False</property>
-		  <property name="fill">False</property>
-		</packing>
-	      </child>
-	    </widget>
-	    <packing>
-	      <property name="tab_expand">False</property>
-	      <property name="tab_fill">True</property>
-	    </packing>
-	  </child>
-
-	  <child>
-	    <widget class="GtkLabel" id="label4">
-	      <property name="visible">True</property>
-	      <property name="label" translatable="yes">O_ptions</property>
-	      <property name="use_underline">True</property>
-	      <property name="use_markup">False</property>
-	      <property name="justify">GTK_JUSTIFY_CENTER</property>
-	      <property name="wrap">False</property>
-	      <property name="selectable">False</property>
-	      <property name="xalign">0.5</property>
-	      <property name="yalign">0.5</property>
-	      <property name="xpad">0</property>
-	      <property name="ypad">0</property>
-	    </widget>
-	    <packing>
-	      <property name="type">tab</property>
-	    </packing>
-	  </child>
-
-	  <child>
-	    <widget class="GtkHBox" id="dao">
-	      <property name="visible">True</property>
-	      <property name="homogeneous">False</property>
-	      <property name="spacing">0</property>
-
-	      <child>
-		<placeholder/>
-	      </child>
-	    </widget>
-	    <packing>
-	      <property name="tab_expand">False</property>
-	      <property name="tab_fill">True</property>
-	    </packing>
-	  </child>
-
-	  <child>
-	    <widget class="GtkLabel" id="label5">
-	      <property name="visible">True</property>
-	      <property name="label" translatable="yes">_Output</property>
-	      <property name="use_underline">True</property>
-	      <property name="use_markup">False</property>
-	      <property name="justify">GTK_JUSTIFY_CENTER</property>
-	      <property name="wrap">False</property>
-	      <property name="selectable">False</property>
-	      <property name="xalign">0.5</property>
-	      <property name="yalign">0.5</property>
-	      <property name="xpad">0</property>
-	      <property name="ypad">0</property>
-	    </widget>
-	    <packing>
-	      <property name="type">tab</property>
-	    </packing>
-	  </child>
-	</widget>
-	<packing>
-	  <property name="padding">0</property>
-	  <property name="expand">True</property>
-	  <property name="fill">True</property>
-	</packing>
-      </child>
-
-      <child>
-	<widget class="GtkLabel" id="warnings">
-	  <property name="visible">True</property>
-	  <property name="label" translatable="yes"></property>
-	  <property name="use_underline">False</property>
-	  <property name="use_markup">False</property>
-	  <property name="justify">GTK_JUSTIFY_LEFT</property>
-	  <property name="wrap">True</property>
-	  <property name="selectable">False</property>
-	  <property name="xalign">0.5</property>
-	  <property name="yalign">0.5</property>
-	  <property name="xpad">0</property>
-	  <property name="ypad">0</property>
-	</widget>
-	<packing>
-	  <property name="padding">0</property>
-	  <property name="expand">False</property>
-	  <property name="fill">False</property>
-	</packing>
-      </child>
-    </widget>
-  </child>
-</widget>
-
+  <widget class="GtkDialog" id="Histogram">
+    <property name="border_width">6</property>
+    <property name="title" translatable="yes">Histogram</property>
+    <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
+    <property name="has_separator">False</property>
+    <child internal-child="vbox">
+      <widget class="GtkVBox" id="vbox1">
+        <property name="visible">True</property>
+        <property name="spacing">6</property>
+        <child>
+          <widget class="GtkNotebook" id="notebook1">
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="border_width">5</property>
+            <child>
+              <widget class="GtkTable" id="input-table">
+                <property name="visible">True</property>
+                <property name="border_width">12</property>
+                <property name="n_rows">3</property>
+                <property name="n_columns">2</property>
+                <property name="column_spacing">12</property>
+                <property name="row_spacing">6</property>
+                <child>
+                  <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="GtkHBox" id="hbox1">
+                    <property name="visible">True</property>
+                    <property name="spacing">12</property>
+                    <property name="homogeneous">True</property>
+                    <child>
+                      <widget class="GtkRadioButton" id="grouped_by_col">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="label" translatable="yes">_Columns</property>
+                        <property name="use_underline">True</property>
+                        <property name="response_id">0</property>
+                        <property name="draw_indicator">True</property>
+                      </widget>
+                    </child>
+                    <child>
+                      <widget class="GtkRadioButton" id="grouped_by_row">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="label" translatable="yes">_Rows</property>
+                        <property name="use_underline">True</property>
+                        <property name="response_id">0</property>
+                        <property name="draw_indicator">True</property>
+                        <property name="group">grouped_by_col</property>
+                      </widget>
+                      <packing>
+                        <property name="position">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <widget class="GtkRadioButton" id="grouped_by_area">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="label" translatable="yes">_Areas</property>
+                        <property name="use_underline">True</property>
+                        <property name="response_id">0</property>
+                        <property name="active">True</property>
+                        <property name="draw_indicator">True</property>
+                        <property name="group">grouped_by_col</property>
+                      </widget>
+                      <packing>
+                        <property name="position">2</property>
+                      </packing>
+                    </child>
+                  </widget>
+                  <packing>
+                    <property name="left_attach">1</property>
+                    <property name="right_attach">2</property>
+                    <property name="top_attach">1</property>
+                    <property name="bottom_attach">2</property>
+                    <property name="y_options">GTK_FILL</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkLabel" id="label1">
+                    <property name="visible">True</property>
+                    <property name="xalign">0</property>
+                    <property name="xpad">5</property>
+                    <property name="label" translatable="yes">Grouped by:</property>
+                    <property name="justify">GTK_JUSTIFY_CENTER</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="xpad">5</property>
+                    <property name="label" translatable="yes">Input _range:</property>
+                    <property name="use_underline">True</property>
+                    <property name="justify">GTK_JUSTIFY_RIGHT</property>
+                  </widget>
+                  <packing>
+                    <property name="x_options">GTK_FILL</property>
+                    <property name="y_options"></property>
+                  </packing>
+                </child>
+              </widget>
+            </child>
+            <child>
+              <widget class="GtkLabel" id="label2">
+                <property name="visible">True</property>
+                <property name="label" translatable="yes">_Input</property>
+                <property name="use_underline">True</property>
+                <property name="justify">GTK_JUSTIFY_CENTER</property>
+              </widget>
+              <packing>
+                <property name="type">tab</property>
+                <property name="tab_fill">False</property>
+              </packing>
+            </child>
+            <child>
+              <widget class="GtkVBox" id="vbox4">
+                <property name="visible">True</property>
+                <property name="border_width">12</property>
+                <child>
+                  <widget class="GtkTable" id="bin_table">
+                    <property name="visible">True</property>
+                    <property name="n_rows">3</property>
+                    <property name="n_columns">2</property>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <widget class="GtkRadioButton" id="pre_determined_button">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="label" translatable="yes">_Predetermined cutoffs</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="x_options">GTK_FILL</property>
+                        <property name="y_options"></property>
+                      </packing>
+                    </child>
+                    <child>
+                      <widget class="GtkLabel" id="var2-label">
+                        <property name="visible">True</property>
+                        <property name="xalign">0</property>
+                        <property name="xpad">5</property>
+                        <property name="label" translatable="yes">Cutoff _range:</property>
+                        <property name="use_underline">True</property>
+                        <property name="justify">GTK_JUSTIFY_RIGHT</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>
+                  </widget>
+                </child>
+                <child>
+                  <widget class="GtkHSeparator" id="hseparator2">
+                    <property name="visible">True</property>
+                  </widget>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkTable" id="table2">
+                    <property name="visible">True</property>
+                    <property name="n_rows">4</property>
+                    <property name="n_columns">2</property>
+                    <child>
+                      <widget class="GtkEntry" id="min_entry">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="invisible_char">*</property>
+                      </widget>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="right_attach">2</property>
+                        <property name="top_attach">1</property>
+                        <property name="bottom_attach">2</property>
+                        <property name="y_options"></property>
+                        <property name="y_padding">2</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <widget class="GtkLabel" id="label8">
+                        <property name="visible">True</property>
+                        <property name="xalign">0</property>
+                        <property name="label" translatable="yes">M_inimum cutoff:</property>
+                        <property name="use_underline">True</property>
+                        <property name="mnemonic_widget">min_entry</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>
+                        <property name="x_padding">5</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <widget class="GtkLabel" id="label9">
+                        <property name="visible">True</property>
+                        <property name="xalign">0</property>
+                        <property name="label" translatable="yes">_Number of cutoffs:</property>
+                        <property name="use_underline">True</property>
+                        <property name="mnemonic_widget">n_entry</property>
+                      </widget>
+                      <packing>
+                        <property name="top_attach">3</property>
+                        <property name="bottom_attach">4</property>
+                        <property name="x_options">GTK_FILL</property>
+                        <property name="y_options"></property>
+                        <property name="x_padding">5</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <widget class="GtkLabel" id="label7">
+                        <property name="visible">True</property>
+                        <property name="xalign">0</property>
+                        <property name="label" translatable="yes">Ma_ximum cutoff:</property>
+                        <property name="use_underline">True</property>
+                        <property name="mnemonic_widget">max_entry</property>
+                      </widget>
+                      <packing>
+                        <property name="top_attach">2</property>
+                        <property name="bottom_attach">3</property>
+                        <property name="x_options">GTK_FILL</property>
+                        <property name="y_options"></property>
+                        <property name="x_padding">5</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <widget class="GtkEntry" id="n_entry">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="invisible_char">*</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="y_options"></property>
+                        <property name="y_padding">2</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <widget class="GtkEntry" id="max_entry">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="invisible_char">*</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="y_options"></property>
+                        <property name="y_padding">2</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <widget class="GtkRadioButton" id="calculated_button">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="label" translatable="yes">_Calculated cutoffs</property>
+                        <property name="use_underline">True</property>
+                        <property name="response_id">0</property>
+                        <property name="draw_indicator">True</property>
+                        <property name="group">pre_determined_button</property>
+                      </widget>
+                      <packing>
+                        <property name="right_attach">2</property>
+                        <property name="y_options"></property>
+                      </packing>
+                    </child>
+                  </widget>
+                  <packing>
+                    <property name="padding">5</property>
+                    <property name="position">2</property>
+                  </packing>
+                </child>
+              </widget>
+              <packing>
+                <property name="position">1</property>
+              </packing>
+            </child>
+            <child>
+              <widget class="GtkLabel" id="label3">
+                <property name="visible">True</property>
+                <property name="label" translatable="yes">C_utoffs</property>
+                <property name="use_underline">True</property>
+                <property name="justify">GTK_JUSTIFY_CENTER</property>
+              </widget>
+              <packing>
+                <property name="type">tab</property>
+                <property name="position">1</property>
+                <property name="tab_fill">False</property>
+              </packing>
+            </child>
+            <child>
+              <widget class="GtkVBox" id="vbox2">
+                <property name="visible">True</property>
+                <child>
+                  <widget class="GtkRadioButton" id="bintype_pm_inf_upper">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="label" translatable="yes">(ââ,â), [â,â), â, [â,â), [â,â)</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="bintype_pm_inf_lower">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="label" translatable="yes">(ââ,â], (â,â], â, (â,â], (â,â)</property>
+                    <property name="response_id">0</property>
+                    <property name="active">True</property>
+                    <property name="draw_indicator">True</property>
+                    <property name="group">bintype_pm_inf_upper</property>
+                  </widget>
+                  <packing>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkHSeparator" id="hseparator1">
+                    <property name="visible">True</property>
+                  </widget>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="position">2</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkRadioButton" id="bintype_p_inf_upper">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="label" translatable="yes">[â,â),[â,â),â,[â,â),[â,â)</property>
+                    <property name="response_id">0</property>
+                    <property name="active">True</property>
+                    <property name="draw_indicator">True</property>
+                    <property name="group">bintype_pm_inf_upper</property>
+                  </widget>
+                  <packing>
+                    <property name="position">3</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkRadioButton" id="bintype_p_inf_lower">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="label" translatable="yes">(â,â],(â,â],â,(â,â],(â,â)</property>
+                    <property name="response_id">0</property>
+                    <property name="active">True</property>
+                    <property name="draw_indicator">True</property>
+                    <property name="group">bintype_pm_inf_upper</property>
+                  </widget>
+                  <packing>
+                    <property name="position">4</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkRadioButton" id="bintype_m_inf_upper">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="label" translatable="yes">(ââ,â),[â,â),â,[â,â),[â,â)</property>
+                    <property name="response_id">0</property>
+                    <property name="active">True</property>
+                    <property name="draw_indicator">True</property>
+                    <property name="group">bintype_pm_inf_upper</property>
+                  </widget>
+                  <packing>
+                    <property name="position">5</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkRadioButton" id="bintype_m_inf_lower">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="label" translatable="yes">(ââ,â],(â,â],â,(â,â],(â,â]</property>
+                    <property name="response_id">0</property>
+                    <property name="active">True</property>
+                    <property name="draw_indicator">True</property>
+                    <property name="group">bintype_pm_inf_upper</property>
+                  </widget>
+                  <packing>
+                    <property name="position">6</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkHSeparator" id="hseparator3">
+                    <property name="visible">True</property>
+                  </widget>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="position">7</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkRadioButton" id="bintype_no_inf_upper">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="label" translatable="yes">[â,â),[â,â),â,[â,â),[â,â)</property>
+                    <property name="response_id">0</property>
+                    <property name="active">True</property>
+                    <property name="draw_indicator">True</property>
+                    <property name="group">bintype_pm_inf_upper</property>
+                  </widget>
+                  <packing>
+                    <property name="position">8</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkRadioButton" id="bintype_no_inf_lower">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="label" translatable="yes">(â,â],(â,â],â,(â,â],(â,â]</property>
+                    <property name="response_id">0</property>
+                    <property name="active">True</property>
+                    <property name="draw_indicator">True</property>
+                    <property name="group">bintype_pm_inf_upper</property>
+                  </widget>
+                  <packing>
+                    <property name="position">9</property>
+                  </packing>
+                </child>
+              </widget>
+              <packing>
+                <property name="position">2</property>
+              </packing>
+            </child>
+            <child>
+              <widget class="GtkLabel" id="label5">
+                <property name="visible">True</property>
+                <property name="label" translatable="yes">_Bins</property>
+                <property name="use_underline">True</property>
+                <property name="justify">GTK_JUSTIFY_CENTER</property>
+              </widget>
+              <packing>
+                <property name="type">tab</property>
+                <property name="position">4</property>
+                <property name="tab_fill">False</property>
+              </packing>
+            </child>
+            <child>
+              <widget class="GtkVBox" id="vbox3">
+                <property name="visible">True</property>
+                <property name="border_width">12</property>
+                <property name="spacing">6</property>
+                <child>
+                  <widget class="GtkCheckButton" id="percentage-button">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="label" translatable="yes">_Percentages</property>
+                    <property name="use_underline">True</property>
+                    <property name="response_id">0</property>
+                    <property name="draw_indicator">True</property>
+                  </widget>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">False</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkCheckButton" id="cum-button">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="label" translatable="yes">C_umulative answers</property>
+                    <property name="use_underline">True</property>
+                    <property name="response_id">0</property>
+                    <property name="draw_indicator">True</property>
+                  </widget>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">False</property>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkCheckButton" id="chart-button">
+                    <property name="visible">True</property>
+                    <property name="sensitive">False</property>
+                    <property name="can_focus">True</property>
+                    <property name="label" translatable="yes">_Chart output</property>
+                    <property name="use_underline">True</property>
+                    <property name="response_id">0</property>
+                    <property name="draw_indicator">True</property>
+                  </widget>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">False</property>
+                    <property name="position">2</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkTable" id="table1">
+                    <property name="visible">True</property>
+                    <property name="n_rows">3</property>
+                    <property name="n_columns">2</property>
+                    <property name="column_spacing">20</property>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <widget class="GtkRadioButton" id="columnchart-button">
+                        <property name="visible">True</property>
+                        <property name="sensitive">False</property>
+                        <property name="can_focus">True</property>
+                        <property name="label" translatable="yes">Column chart</property>
+                        <property name="response_id">0</property>
+                        <property name="active">True</property>
+                        <property name="draw_indicator">True</property>
+                        <property name="group">barchart-button</property>
+                      </widget>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="right_attach">2</property>
+                        <property name="top_attach">1</property>
+                        <property name="bottom_attach">2</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <widget class="GtkRadioButton" id="histogram-button">
+                        <property name="visible">True</property>
+                        <property name="sensitive">False</property>
+                        <property name="can_focus">True</property>
+                        <property name="label" translatable="yes">Histogram chart</property>
+                        <property name="response_id">0</property>
+                        <property name="draw_indicator">True</property>
+                        <property name="group">barchart-button</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>
+                      </packing>
+                    </child>
+                    <child>
+                      <widget class="GtkRadioButton" id="barchart-button">
+                        <property name="visible">True</property>
+                        <property name="sensitive">False</property>
+                        <property name="can_focus">True</property>
+                        <property name="label" translatable="yes">Bar chart</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>
+                      </packing>
+                    </child>
+                  </widget>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">False</property>
+                    <property name="position">3</property>
+                  </packing>
+                </child>
+              </widget>
+              <packing>
+                <property name="position">3</property>
+              </packing>
+            </child>
+            <child>
+              <widget class="GtkLabel" id="label4">
+                <property name="visible">True</property>
+                <property name="label" translatable="yes">O_ptions</property>
+                <property name="use_underline">True</property>
+                <property name="justify">GTK_JUSTIFY_CENTER</property>
+              </widget>
+              <packing>
+                <property name="type">tab</property>
+                <property name="position">3</property>
+                <property name="tab_fill">False</property>
+              </packing>
+            </child>
+            <child>
+              <widget class="GtkHBox" id="dao">
+                <property name="visible">True</property>
+                <child>
+                  <placeholder/>
+                </child>
+              </widget>
+              <packing>
+                <property name="position">4</property>
+              </packing>
+            </child>
+            <child>
+              <widget class="GtkLabel" id="label6">
+                <property name="visible">True</property>
+                <property name="label" translatable="yes">_Output</property>
+                <property name="use_underline">True</property>
+              </widget>
+              <packing>
+                <property name="type">tab</property>
+                <property name="position">4</property>
+                <property name="tab_fill">False</property>
+              </packing>
+            </child>
+          </widget>
+          <packing>
+            <property name="position">1</property>
+          </packing>
+        </child>
+        <child>
+          <widget class="GtkLabel" id="warnings">
+            <property name="visible">True</property>
+            <property name="wrap">True</property>
+          </widget>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="position">2</property>
+          </packing>
+        </child>
+        <child internal-child="action_area">
+          <widget class="GtkHButtonBox" id="hbuttonbox1">
+            <property name="visible">True</property>
+            <property name="layout_style">GTK_BUTTONBOX_END</property>
+            <child>
+              <widget class="GtkButton" id="helpbutton">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="label">gtk-help</property>
+                <property name="use_stock">True</property>
+                <property name="response_id">0</property>
+              </widget>
+            </child>
+            <child>
+              <widget class="GtkButton" id="cancelbutton">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="label">gtk-cancel</property>
+                <property name="use_stock">True</property>
+                <property name="response_id">0</property>
+              </widget>
+              <packing>
+                <property name="position">1</property>
+              </packing>
+            </child>
+            <child>
+              <widget class="GtkButton" id="okbutton">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="has_default">True</property>
+                <property name="label">gtk-ok</property>
+                <property name="use_stock">True</property>
+                <property name="response_id">0</property>
+              </widget>
+              <packing>
+                <property name="position">2</property>
+              </packing>
+            </child>
+          </widget>
+          <packing>
+            <property name="expand">False</property>
+            <property name="pack_type">GTK_PACK_END</property>
+          </packing>
+        </child>
+      </widget>
+    </child>
+  </widget>
 </glade-interface>

Modified: trunk/src/tools/analysis-histogram.c
==============================================================================
--- trunk/src/tools/analysis-histogram.c	(original)
+++ trunk/src/tools/analysis-histogram.c	Tue Sep 16 05:51:15 2008
@@ -1,16 +1,14 @@
 /* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
 /*
-** analysis-histogram.c
-** 
-** Made by (Solarion)
-** Login   <gnumeric-hacker digitasaru net>
-** 
-** Started on  Mon Dec  4 20:37:18 2006 Johnny Q. Hacker
-** Last update Wed Dec  6 20:10:55 2006 Johnny Q. Hacker
-*
- * (C) Copyright 2000, 2001 by Jukka-Pekka Iivonen <jiivonen hutcs cs hut fi>
- * (C) Copyright 2002, 2004 by Andreas J. Guelzow  <aguelzow taliesin ca>
- * (C) Copyright 2006 by Solarion <gnumeric-hacker digitasaru net>
+ * analysis-histogram.c:
+ *
+  * This is a complete reimplementation of the histogram tool in 2008
+ *
+ * Author:
+ *   Andreas J. Guelzow  <aguelzow pyrshep ca>
+ *
+ * (C) Copyright 2008 by Andreas J. Guelzow  <aguelzow pyrshep ca>
+ *
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -25,385 +23,308 @@
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- *Original version imported wholesale from analysis-tools.c
  */
 
 #include <gnumeric-config.h>
 #include <glib/gi18n-lib.h>
 #include "gnumeric.h"
-#include "mathfunc.h"
-#include "func.h"
-#include "expr.h"
-#include "position.h"
-#include "complex.h"
-#include "rangefunc.h"
-#include "tools.h"
+#include "analysis-histogram.h"
+#include "analysis-tools.h"
 #include "value.h"
-#include "cell.h"
-#include "sheet.h"
 #include "ranges.h"
-#include "style.h"
-#include "regression.h"
-#include "sheet-style.h"
-#include "workbook.h"
-#include "gnm-format.h"
-#include "sheet-object-cell-comment.h"
-#include "workbook-control.h"
-#include "command-context.h"
-#include "analysis-tools.h"
-#include "analysis-histogram.h"
-#include <goffice/utils/go-glib-extras.h>
-
-#include <goffice/utils/go-glib-extras.h>
+#include "expr.h"
+#include "func.h"
+#include "numbers.h"
 
-#include <string.h>
-#include <stdlib.h>
-#include <math.h>
+static gboolean
+analysis_tool_histogram_engine_run (data_analysis_output_t *dao,
+				    analysis_tools_data_histogram_t *info)
+{
+	GnmRange range;
+	gint i, i_limit, i_start, i_end, col;
+	GSList *l;
+	GnmExprOp from, to;
+	gint to_col = (info->cumulative) ? 0 : 1;
+
+	GnmExpr const *expr_bin = NULL;
+
+	GnmFunc *fd_small;
+	GnmFunc *fd_sum;
+	GnmFunc *fd_if;
+	GnmFunc *fd_index = NULL;
+	GnmFunc *fd_count = NULL;
+
+	char const *format;
+
+	fd_small = gnm_func_lookup ("SMALL", NULL);
+	gnm_func_ref (fd_small);
+	fd_sum = gnm_func_lookup ("SUM", NULL);
+	gnm_func_ref (fd_sum);
+	fd_if = gnm_func_lookup ("IF", NULL);
+	gnm_func_ref (fd_if);
+
+	if (info->base.labels) {
+		fd_index = gnm_func_lookup ("INDEX", NULL);
+		gnm_func_ref (fd_index);		
+	}
+	if (info->percentage) {
+		fd_count = gnm_func_lookup ("COUNT", NULL);
+		gnm_func_ref (fd_count);		
+	}
+	
 
-/************* Histogram Tool *********************************************
- *
- * The results are given in a table which can be printed out in a new
- * sheet, in a new workbook, or simply into an existing sheet.
- *
- **/
+	/* General Info */
 
-typedef struct {
-	gnm_float limit;
-	GArray     *counts;
-	char       *label;
-	gboolean   strict;
-	gboolean   first;
-	gboolean   last;
-	gboolean   destroy_label;
-} bin_t;
+	dao_set_italic (dao, 0, 0, 0, 0);
+	dao_set_cell (dao, 0, 0, _("Histogram"));
 
-static gint
-bin_compare (bin_t const *set_a, bin_t const *set_b)
-{
-	gnm_float a, b;
+	/* Setting up the bins */
 
-	a = set_a->limit;
-	b = set_b->limit;
+	if (info->predetermined) {
+		range_init_value (&range, info->bin);
+		i_limit = range_height (&range) * range_width (&range);
+	} else {
+		i_limit = info->n;
+	}
+	
+	i_end = i_limit;
+	if (info->bin_type & bintype_p_inf_lower)
+		i_end++;
+	if (info->bin_type & bintype_m_inf_lower)
+		i_end++;
+	dao_set_format  (dao, to_col, 1, to_col, 1, "\"\";\"\"");
+	format = (info->bin_type & bintype_no_inf_upper) ?
+		/* translator note: do not translate the "General" */
+		/* part of the following strings.*/
+		_("\"to below\" * General") : _("\"up to\" * General");
+	dao_set_format  (dao, to_col, 2, to_col, i_end, format);
+
+	if (info->bin_type & bintype_m_inf_lower) {
+		dao_set_cell_expr (dao, to_col, 1, 
+				   gnm_expr_new_constant (value_new_float (-GNM_MAX)));
+		i_start = 2;
+	} else
+		i_start = 1;
+
+	if (info->predetermined) {
+		expr_bin = gnm_expr_new_constant (info->bin);
+		for (i = 0; i < i_limit; i++)
+			dao_set_cell_expr (dao, to_col, i_start + i, 
+					   gnm_expr_new_funcall2 (fd_small,
+								  gnm_expr_copy (expr_bin),
+								  gnm_expr_new_constant 
+								  (value_new_int (i + 1))));
+	} else {
+		GnmValue *val = value_dup (info->base.input->data);
+		GnmExpr const *expr_min;
+		GnmExpr const *expr_max;
+		
+		switch (info->base.group_by) {
+		case GROUPED_BY_ROW:
+			val->v_range.cell.a.col++;
+			break;
+		default:
+			val->v_range.cell.a.row++;
+			break;
+		}
+		
+		if (info->min_given)
+			dao_set_cell_float (dao, to_col, i_start, info->min);
+		else {
+			GnmFunc *fd_min;
+		
+			fd_min = gnm_func_lookup ("MIN", NULL);
+			gnm_func_ref (fd_min);
+			dao_set_cell_expr (dao, to_col, i_start,
+					   gnm_expr_new_funcall1 
+					   (fd_min,
+					    gnm_expr_new_constant (value_dup (val))));
+			gnm_func_unref (fd_min);
+		}
 
-        if (a < b)
-                return -1;
-        else if (a == b)
-                return 0;
-        else
-                return 1;
-}
+		if (info->max_given)
+			dao_set_cell_float (dao, to_col, i_start + i_limit - 1, info->max);
+		else {
+			GnmFunc *fd_max;
+		
+			fd_max = gnm_func_lookup ("MAX", NULL);
+			gnm_func_ref (fd_max);
+			dao_set_cell_expr (dao, to_col, i_start + i_limit - 1,
+					   gnm_expr_new_funcall1 
+					   (fd_max,
+					    gnm_expr_new_constant (value_dup (val))));
+			gnm_func_unref (fd_max);
+		}
 
-static gint
-bin_pareto_at_i (bin_t const *set_a, bin_t const *set_b, guint index)
-{
-	gnm_float a, b;
+		value_release (val);
+		
+		expr_min = dao_get_cellref (dao, to_col, i_start);
+		expr_max = dao_get_cellref (dao, to_col, i_start + i_limit - 1);
+
+		for (i = 1; i < i_limit - 1; i++)
+			dao_set_cell_expr (dao, to_col, i_start + i, 
+					   gnm_expr_new_binary (gnm_expr_copy (expr_min),
+								GNM_EXPR_OP_ADD,
+								gnm_expr_new_binary 
+								(gnm_expr_new_constant (value_new_int (i)),
+								 GNM_EXPR_OP_MULT,
+								 gnm_expr_new_binary 
+								 (gnm_expr_new_binary 
+								  (gnm_expr_copy (expr_max), 
+								   GNM_EXPR_OP_SUB, 
+								   gnm_expr_copy (expr_min)), 
+								  GNM_EXPR_OP_DIV,
+								  gnm_expr_new_constant (value_new_int (info->n))))));
+		
+		gnm_expr_free (expr_min);
+		gnm_expr_free (expr_max);
+	}
+	
+	if (info->bin_type & bintype_p_inf_lower) {
+		dao_set_format  (dao, to_col, i_end, to_col, i_end, 
+				 _("\"to\" * \"\xe2\x88\x9e\""));
+		dao_set_cell_expr (dao, to_col, i_end, 
+				   gnm_expr_new_constant (value_new_float (GNM_MAX)));
+	}
 
-	if (set_a->counts->len <= index)
-		return 0;
+	/* format the lower end of the bins */
 
-	a = g_array_index (set_a->counts, gnm_float, index);
-	b = g_array_index (set_b->counts, gnm_float, index);
+	if (!info->cumulative) {
+		GnmExpr const *expr_cr = make_cellref (1,-1);
 
-        if (a > b)
-                return -1;
-        else if (a == b)
-                return bin_pareto_at_i (set_a, set_b, index + 1);
-        else
-                return 1;
-}
+		format = (info->bin_type & bintype_no_inf_upper) ?
+			/* translator note: do not translate the "General" part */
+			/* of the following strings.*/
+			_("\"from\" * General") : _("\"above\" * General");
+		dao_set_format  (dao, 0, 2, 0, i_end, format);
+		if (info->bin_type & bintype_m_inf_lower)
+			dao_set_format  (dao, 0, 2, 0, 2, 
+					 _("\"from\" * \"\xe2\x88\x92\xe2\x88\x9e\";"
+					   "\"from\" * \"\xe2\x88\x92\xe2\x88\x9e\""));
+		for (i = 2; i <= i_end; i++)
+			dao_set_cell_expr (dao, 0, i, gnm_expr_copy (expr_cr));
 
-static gint
-bin_pareto (bin_t const *set_a, bin_t const *set_b)
-{
-	return bin_pareto_at_i (set_a, set_b, 0);
-}
+		gnm_expr_free (expr_cr);
+	}
 
-static void
-destroy_items (gpointer data)
-{
-	if (((bin_t*)data)->label != NULL && ((bin_t*)data)->destroy_label)
-		g_free (((bin_t*)data)->label);
-	g_free (data);
-}
+	/* insert formulas for histogram values */
 
-static gboolean
-analysis_tool_histogram_engine_run (data_analysis_output_t *dao,
-				    analysis_tools_data_histogram_t *info,
-				    GPtrArray **bin_data)
-{
-	GPtrArray *data = NULL;
-	GSList *bin_list = NULL;
-	bin_t  *a_bin;
-	guint  i, j, row, col;
-	GSList * this;
-	gnm_float *this_value;
-
-	data = new_data_set_list (info->input, info->group_by,
-				  TRUE, info->labels, dao->sheet);
-
-/* set up counter structure */
-	if (info->bin != NULL) {
-		for (i=0; i < (*bin_data)->len; i++) {
-			a_bin = g_new (bin_t, 1);
-			a_bin->limit = g_array_index (
-				((data_set_t *)g_ptr_array_index ((*bin_data), i))->data,
-				gnm_float, 0);
-			a_bin->counts = g_array_new (FALSE, TRUE, sizeof (gnm_float));
-			a_bin->counts = g_array_set_size (a_bin->counts, data->len);
-			a_bin->label = ((data_set_t *)g_ptr_array_index ((*bin_data), i))->label;
-			a_bin->destroy_label = FALSE;
-			a_bin->last = FALSE;
-			a_bin->first = FALSE;
-			a_bin->strict = FALSE;
-			bin_list = g_slist_prepend (bin_list, a_bin);
-		}
-		bin_list = g_slist_sort (bin_list,
-					 (GCompareFunc) bin_compare);
+	if (info->bin_type & bintype_p_inf_lower) {
+		from = GNM_EXPR_OP_LTE;
+		to = GNM_EXPR_OP_GT;
 	} else {
-		gnm_float skip;
-		gboolean value_set;
-		char        *text;
-		GnmValue       *val;
-
-		if (!info->max_given) {
-			value_set = FALSE;
-			for (i = 0; i < data->len; i++) {
-				GArray * the_data;
-				gnm_float a_max;
-				the_data = ((data_set_t *)(g_ptr_array_index (data, i)))->data;
-				if (0 == gnm_range_max ((gnm_float *)the_data->data, the_data->len,
-						    &a_max)) {
-					if (value_set) {
-						if (a_max > info->max)
-							info->max = a_max;
-					} else {
-						info->max = a_max;
-						value_set = TRUE;
-					}
-				}
+		from = GNM_EXPR_OP_LT;
+		to = GNM_EXPR_OP_GTE;
+	}
+
+	for (l = info->base.input, col = to_col + 1; l; col++, l = l->next) {
+		GnmValue *val = l->data;
+		GnmValue *val_c = NULL;
+		GnmExpr const *expr_count;
+		GnmExpr const *expr_data;
+		GnmExpr const *expr_if_from;
+		GnmExpr const *expr_if_to;
+
+		
+		if (info->base.labels) {
+			val_c = value_dup (val);
+			switch (info->base.group_by) {
+			case GROUPED_BY_ROW:
+				val->v_range.cell.a.col++;
+				break;
+			default:
+				val->v_range.cell.a.row++;
+				break;
 			}
-			if (!value_set)
-				info->max = 0.0;
-		}
-		if (!info->min_given) {
-			value_set = FALSE;
-			for (i = 0; i < data->len; i++) {
-				GArray * the_data;
-				gnm_float a_min;
-				the_data = ((data_set_t *)(g_ptr_array_index (data, i)))->data;
-				if (0 == gnm_range_min ((gnm_float *)the_data->data, the_data->len,
-						    &a_min)) {
-					if (value_set) {
-						if (a_min < info->min)
-							info->min = a_min;
-					} else {
-						info->min = a_min;
-						value_set = TRUE;
-					}
-				}
+			dao_set_cell_expr (dao, col, 1,
+					   gnm_expr_new_funcall1 (fd_index, 
+								  gnm_expr_new_constant (val_c)));
+		} else {
+			char const *format;
+			
+			switch (info->base.group_by) {
+			case GROUPED_BY_ROW:
+				format = _("Row %d");
+				break;
+			case GROUPED_BY_COL:
+				format = _("Column %d");
+				break;
+			default:
+				format = _("Area %d");
+				break;				
 			}
-			if (!value_set)
-				info->min = 0.0;
+			dao_set_cell_printf (dao, col, 1, format, col - to_col);
 		}
 
-		skip = (info->max - info->min) / info->n;
-		for (i = 0; (int)i < info->n;  i++) {
-			a_bin = g_new (bin_t, 1);
-			a_bin->limit = info->max - i * skip;
-			a_bin->counts = g_array_new (FALSE, TRUE, sizeof (gnm_float));
-			a_bin->counts = g_array_set_size (a_bin->counts, data->len);
-			a_bin->label = NULL;
-			a_bin->destroy_label = FALSE;
-			a_bin->last = FALSE;
-			a_bin->first = FALSE;
-			a_bin->strict = FALSE;
-			bin_list = g_slist_prepend (bin_list, a_bin);
-		}
-		a_bin = g_new (bin_t, 1);
-		a_bin->limit = info->min;
-		a_bin->counts = g_array_new (FALSE, TRUE, sizeof (gnm_float));
-		a_bin->counts = g_array_set_size (a_bin->counts, data->len);
-		val = value_new_float(info->min);
-		text = format_value (NULL, val, NULL, 10,
-			workbook_date_conv (dao->sheet->workbook));
-		if (text) {
-			a_bin->label = g_strdup_printf (_("<%s"), text);
-			a_bin->destroy_label = TRUE;
-			g_free (text);
-		} else {
-			a_bin->label = _("Too Small");
-			a_bin->destroy_label = FALSE;
+		expr_data = gnm_expr_new_constant (val);
+		expr_if_to = gnm_expr_new_funcall3
+			(fd_if, 
+			 gnm_expr_new_binary 
+			 (gnm_expr_copy (expr_data), 
+			  to, make_cellref (- (col-to_col), 0)),
+			 gnm_expr_new_constant (value_new_int (0)),
+			 gnm_expr_new_constant (value_new_int (1)));
+		
+		if (info->cumulative)
+			expr_count = gnm_expr_new_funcall1
+				(fd_sum, expr_if_to);
+		else {
+			expr_if_from = gnm_expr_new_funcall3
+				(fd_if, 
+				 gnm_expr_new_binary 
+				 (gnm_expr_copy (expr_data), 
+				  from, make_cellref (- col, 0)),
+				 gnm_expr_new_constant (value_new_int (0)),
+				 gnm_expr_new_constant (value_new_int (1)));
+			expr_count = gnm_expr_new_funcall1
+				(fd_sum,
+				 gnm_expr_new_binary (expr_if_from,
+						      GNM_EXPR_OP_MULT,
+						      expr_if_to));
 		}
-		if (val)
-			value_release (val);
-		a_bin->last = FALSE;
-		a_bin->first = TRUE;
-		a_bin->strict = TRUE;
-		bin_list = g_slist_prepend (bin_list, a_bin);
-		info->bin_labels = FALSE;
-	}
-	a_bin = g_new (bin_t, 1);
-	a_bin->limit = 0.0;
-	a_bin->counts = g_array_new (FALSE, TRUE, sizeof (gnm_float));
-	a_bin->counts = g_array_set_size (a_bin->counts, data->len);
-	a_bin->destroy_label = FALSE;
-	if (info->bin != NULL) {
-		a_bin->label = _("More");
-	} else {
-		char        *text;
-		GnmValue       *val;
 
-		val = value_new_float(info->max);
-		text = format_value (NULL, val, NULL, 10,
-			workbook_date_conv (dao->sheet->workbook));
-		if (text) {
-			a_bin->label = g_strdup_printf (_(">%s"), text);
-			a_bin->destroy_label = TRUE;
-			g_free (text);
+		if (info->percentage) {
+			dao_set_format  (dao, col, 2, col, i_end, "0.0%");
+			expr_count = gnm_expr_new_binary (expr_count,
+							  GNM_EXPR_OP_DIV,
+							  gnm_expr_new_funcall1 
+							  (fd_count, 
+							   expr_data));
 		} else
-			a_bin->label = _("Too Large");
-		if (val)
-			value_release (val);
-	}
-	a_bin->last = TRUE;
-	a_bin->first = FALSE;
-	a_bin->strict = FALSE;
-	bin_list = g_slist_append (bin_list, a_bin);
-
-/* count data */
-	for (i = 0; i < data->len; i++) {
-		GArray * the_data;
-		gnm_float *the_sorted_data;
-
-		the_data = ((data_set_t *)(g_ptr_array_index (data, i)))->data;
-		the_sorted_data =  range_sort ((gnm_float *)(the_data->data), the_data->len);
-
-		this = bin_list;
-		this_value = the_sorted_data;
-
-		for (j = 0; j < the_data->len;) {
-			if ((*this_value < ((bin_t *)this->data)->limit) ||
-			    (*this_value == ((bin_t *)this->data)->limit &&
-			     !((bin_t *)this->data)->strict) ||
-			    (this->next == NULL)){
-				(g_array_index (((bin_t *)this->data)->counts,
-						gnm_float, i))++;
-				j++;
-				this_value++;
-			} else {
-				this = this->next;
-			}
-		}
-		g_free (the_sorted_data);
-	}
+			gnm_expr_free (expr_data);
 
-/* sort if pareto */
-	if (info->pareto && (data->len > 0))
-		bin_list = g_slist_sort (bin_list,
-					 (GCompareFunc) bin_pareto);
-
-/* print labels */
-	row = info->labels ? 1 : 0;
-	if (!info->bin_labels)
-		dao_set_cell (dao, 0, row, _("Bin"));
-
-	this = bin_list;
-	while (this != NULL) {
-		row++;
-		if (info->bin_labels || ((bin_t *)this->data)->last || ((bin_t *)this->data)->first) {
-			dao_set_cell (dao, 0, row, ((bin_t *)this->data)->label);
-		} else {
-			dao_set_cell_float (dao, 0, row, ((bin_t *)this->data)->limit);
-		}
-		this = this->next;
+		for (i = 2; i <= i_end; i++)
+			dao_set_cell_array_expr (dao, col, i, gnm_expr_copy (expr_count));
+		
+		gnm_expr_free (expr_count);
 	}
-	dao_set_italic (dao, 0, 0, 0, row);
 
-	col = 1;
-	for (i = 0; i < data->len; i++) {
-		guint l_col = col;
-		gnm_float y = 0.0;
-		row = 0;
-
-		if (info->labels) {
-			dao_set_cell (dao, col, row,
-				  ((data_set_t *)g_ptr_array_index (data, i))->label);
-			row++;
-		}
-		dao_set_cell (dao, col, row, _("Frequency"));
-		if (info->percentage)
-			dao_set_cell (dao, ++l_col, row, _("%"));
-		if (info->cumulative)
-			/* xgettext:no-c-format */
-			dao_set_cell (dao, ++l_col, row, _("Cumulative %"));
-/* print data */
-		this = bin_list;
-		while (this != NULL) {
-			gnm_float x;
-
-			l_col = col;
-			x = g_array_index (((bin_t *)this->data)->counts, gnm_float, i);
-			row ++;
-			dao_set_cell_float (dao, col, row,  x);
-			x /= ((data_set_t *)(g_ptr_array_index (data, i)))->data->len;
-			if (info->percentage) {
-				l_col++;
-				dao_set_percent (dao, l_col, row, l_col, row);
-				dao_set_cell_float (dao, l_col, row, x);
-			}
-			if (info->cumulative) {
-				y += x;
-				l_col++;
-				dao_set_percent (dao, l_col, row, l_col, row);
-				dao_set_cell_float (dao, l_col, row, y);
-			}
-			this = this->next;
-		}
-		col++;
-		if (info->percentage)
-			col++;
-		if (info->cumulative)
-			col++;
-	}
-	dao_set_italic (dao, 0, 0,  col - 1, info->labels ? 1 : 0);
 
-/* finish up */
-	destroy_data_set_list (data);
-	go_slist_free_custom (bin_list, destroy_items);
-
-	if (*bin_data) {
-		destroy_data_set_list (*bin_data);
-		*bin_data = NULL;
-	}
+	if (expr_bin != NULL)
+		gnm_expr_free (expr_bin);
+
+	gnm_func_unref (fd_small);
+	gnm_func_unref (fd_if);
+	gnm_func_unref (fd_sum);
+	if (fd_index != NULL)
+		gnm_func_unref (fd_index);
+	if (fd_count != NULL)
+		gnm_func_unref (fd_count);
+
+	dao_redraw_respan (dao);
 
-	if (info->chart)
-		g_warning ("TODO : tie this into the graph generator");
 	return FALSE;
 }
 
-static gboolean
-analysis_tool_histogram_engine_check_bins (data_analysis_output_t *dao,
-					   analysis_tools_data_histogram_t *info,
-					   GPtrArray **bin_data_cont)
-{
-	GPtrArray *bin_data = NULL;
-	guint  i;
-
-	if (info->bin == NULL)
-		return FALSE;
 
-	bin_data = new_data_set_list (info->bin, GROUPED_BY_BIN,
-				      TRUE, info->bin_labels, dao->sheet);
-	for (i = 0; i < bin_data->len; i++) {
-		if (((data_set_t *)g_ptr_array_index (bin_data, i))->data->len != 1) {
-			destroy_data_set_list (bin_data);
-			return TRUE;
-		}
-	}
-	*bin_data_cont = bin_data;
+static gint
+calc_length (GnmValue   *bin)
+{
+	g_return_val_if_fail (bin != NULL, 0);
+	g_return_val_if_fail (bin->type == VALUE_CELLRANGE, 0);
 
-	return FALSE;
+	return ((bin->v_range.cell.b.col - bin->v_range.cell.a.col + 1) * 
+		(bin->v_range.cell.b.row - bin->v_range.cell.a.row + 1));
 }
 
 gboolean
@@ -417,21 +338,27 @@
 		return (dao_command_descriptor (dao, _("Histogram (%s)"), result)
 			== NULL);
 	case TOOL_ENGINE_UPDATE_DAO:
-		prepare_input_range (&info->input, info->group_by);
-		if (info->bin)
-			prepare_input_range (&info->bin, GROUPED_BY_ROW);
-		dao_adjust (dao,
-			    1 + (1 + (info->cumulative ? 1 : 0) +
-				 (info->percentage ? 1 : 0)) * g_slist_length (info->input),
-			    2 + (info->bin ? (int)g_slist_length (info->bin) : info->n) +
-			    (info->labels ? 1 : 0));
+	{
+		int i, j;
+
+		prepare_input_range (&info->base.input, info->base.group_by);
+
+		i = 1 + ((info->predetermined) ? calc_length (info->bin) : info->n);
+		if (info->bin_type & bintype_p_inf_lower)
+			i++;
+		if (info->bin_type & bintype_m_inf_lower)
+			i++;
+
+		j = g_slist_length (info->base.input) + ((info->cumulative) ? 1 : 2);
+
+		dao_adjust (dao, j, i);
+
 		return FALSE;
+	}
 	case TOOL_ENGINE_CLEAN_UP:
-		range_list_destroy (info->input);
-		range_list_destroy (info->bin);
 		return FALSE;
 	case TOOL_ENGINE_LAST_VALIDITY_CHECK:
-		return analysis_tool_histogram_engine_check_bins (dao, specs, result);
+		return FALSE;
 	case TOOL_ENGINE_PREPARE_OUTPUT_RANGE:
 		dao_prepare_output (NULL, dao, _("Histogram"));
 		return FALSE;
@@ -439,7 +366,11 @@
 		return dao_format_output (dao, _("Histogram"));
 	case TOOL_ENGINE_PERFORM_CALC:
 	default:
-		return analysis_tool_histogram_engine_run (dao, specs, result);
+		return analysis_tool_histogram_engine_run (dao, specs);
 	}
-	return TRUE;  /* We shouldn't get here */
+	return TRUE;
 }
+
+
+
+

Modified: trunk/src/tools/analysis-histogram.h
==============================================================================
--- trunk/src/tools/analysis-histogram.h	(original)
+++ trunk/src/tools/analysis-histogram.h	Tue Sep 16 05:51:15 2008
@@ -1,37 +1,67 @@
+/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
 /*
-** analysis-histogram.h
-** 
-** Made by Solarion
-** Login   <gnumeric-hacker digitasaru net>
-** 
-** Started on  Mon Dec  4 20:36:28 2006 Johnny Q. Hacker
-** Last update Wed Dec  6 20:11:39 2006 Johnny Q. Hacker
-*/
+ * analysis-histogram.h:
+ *
+ * This is a complete reimplementation of the histogram tool in 2008
+ *
+ * Author:
+ *   Andreas J. Guelzow  <aguelzow pyrshep ca>
+ *
+ * (C) Copyright 2008 by Andreas J. Guelzow  <aguelzow pyrshep ca>
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
 
 #ifndef ANALYSIS_HISTOGRAM_H
 #define ANALYSIS_HISTOGRAM_H
 
+#include "gnumeric.h"
+#include "numbers.h"
+#include "dao.h"
+#include "tools.h"
+#include "analysis-tools.h"
+
+typedef enum {
+	bintype_no_inf_lower = 0,
+	bintype_no_inf_upper = 1 << 0,
+	bintype_p_inf_lower  = 1 << 1,
+	bintype_p_inf_upper  = bintype_no_inf_upper | bintype_p_inf_lower,
+	bintype_m_inf_lower  = 1 << 2,
+	bintype_m_inf_upper  = bintype_m_inf_lower | bintype_no_inf_upper, 
+	bintype_pm_inf_lower = bintype_m_inf_lower | bintype_p_inf_lower,
+	bintype_pm_inf_upper = bintype_m_inf_lower | bintype_p_inf_lower | bintype_no_inf_upper
+} analysis_histogram_bin_type_t;
+
 typedef struct {
-	analysis_tools_error_code_t err;
-	WorkbookControl *wbc;
-	GSList     *input;
-	GSList     *bin;
-	group_by_t group_by;
-	gboolean   labels;
-	gboolean   bin_labels;
-	gboolean   pareto;
-	gboolean   percentage;
-	gboolean   cumulative;
-	gboolean   chart;
+	analysis_tools_data_generic_t base;
+	gboolean   predetermined;
+	GnmValue   *bin;
+	analysis_histogram_bin_type_t   bin_type;
 	gboolean   max_given;
 	gboolean   min_given;
 	gnm_float max;
 	gnm_float min;
 	gint       n;
-
+	gboolean   percentage;
+	gboolean   cumulative;
+	gboolean   chart;	
 } analysis_tools_data_histogram_t;
 
 gboolean analysis_tool_histogram_engine (data_analysis_output_t *dao, gpointer specs,
 					   analysis_tool_engine_t selector, gpointer result);
 
-#endif 	    /* !ANALYSIS_HISTOGRAM_H */
+#endif

Modified: trunk/src/tools/analysis-tools.c
==============================================================================
--- trunk/src/tools/analysis-tools.c	(original)
+++ trunk/src/tools/analysis-tools.c	Tue Sep 16 05:51:15 2008
@@ -57,7 +57,7 @@
 #include <math.h>
 
 
-static const GnmExpr *
+const GnmExpr *
 make_cellref (int dx, int dy)
 {
 	GnmCellRef r;
@@ -70,6 +70,24 @@
 }
 
 
+/*************************************************************************/
+/*
+ *  data_set_t: a data set format (optionally) keeping track of missing
+ *  observations.
+ *
+ */
+typedef struct {
+        GArray  *data;
+	char *label;
+	GSList *missing;
+	gboolean complete;
+	gboolean read_label;
+} data_set_t;
+
+
+static gboolean 
+gnm_check_input_range_list_homogeneity (GSList *input_range);
+
 typedef struct {
 	char *format;
 	GPtrArray *data_lists;
@@ -248,7 +266,7 @@
  *  destroy_data_set_list:
  *  @the_list:
  */
-void
+static void
 destroy_data_set_list (GPtrArray * the_list)
 {
 	guint i;

Modified: trunk/src/tools/analysis-tools.h
==============================================================================
--- trunk/src/tools/analysis-tools.h	(original)
+++ trunk/src/tools/analysis-tools.h	Tue Sep 16 05:51:15 2008
@@ -226,21 +226,7 @@
 gboolean analysis_tool_anova_two_factor_engine (data_analysis_output_t *dao, gpointer specs,
 					   analysis_tool_engine_t selector, gpointer result);
 
-/*THINGS NEEDED FOR THE HISTOGRAM SPLIT-OUT
- *We will almost certainly move these around further later, but for
- *now, getting things to work (and particularly compile) is more
- *important.
- */
-/*
- *  new_data_set_list:
- *  @ranges: GSList *           the data location
- *  @group_by: group_by_t       how to group the data
- *  @ignore_non_num: gboolean   whether simply to ignore non-numerical values
- *  @read_label: gboolean       whether the first entry contains a label
- */
-GPtrArray *
-new_data_set_list (GSList *ranges, group_by_t group_by,
-		   gboolean ignore_non_num, gboolean read_labels, Sheet *sheet);
+/* THINGS NEEDED FOR THE HISTOGRAM SPLIT-OUT */
 
 /*
  *  prepare_input_range:
@@ -248,35 +234,11 @@
  *  @group_by:
  *
  */
-void
-prepare_input_range (GSList **input_range, group_by_t group_by);
-
-
-/*************************************************************************/
-/*
- *  data_set_t: a data set format (optionally) keeping track of missing
- *  observations.
- *
- */
-typedef struct {
-        GArray  *data;
-	char *label;
-	GSList *missing;
-	gboolean complete;
-	gboolean read_label;
-} data_set_t;
-
-/*
- *  destroy_data_set_list:
- *  @the_list:
- */
-void
-destroy_data_set_list (GPtrArray * the_list);
+void prepare_input_range (GSList **input_range, group_by_t group_by);
 
-gnm_float *
-range_sort (gnm_float const *xs, int n);
+const GnmExpr *make_cellref (int dx, int dy);
 
-gboolean gnm_check_input_range_list_homogeneity (GSList *input_range);
+gnm_float *range_sort (gnm_float const *xs, int n);
 
 void gnm_fourier_fft (complex_t const *in, int n, int skip,
 					  complex_t **fourier, gboolean inverse);



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