[gnumeric] Add axis title to chart in histogram tool. [#408]



commit c7e6f3cbf7b0cb29e2d8d1db97c83ca07c1cfac1
Author: Andreas J. Guelzow <aguelzow pyrshep ca>
Date:   Sat May 9 21:57:01 2020 -0600

    Add axis title to chart in histogram tool. [#408]
    
    2020-05-09  Andreas J. Guelzow <aguelzow pyrshep ca>
    
            * analysis-histogram.c (analysis_tool_histogram_engine_run):
            add axis title to chart

 NEWS                           |  3 +++
 src/tools/ChangeLog            |  5 +++++
 src/tools/analysis-histogram.c | 39 +++++++++++++++++++++++++++++++++++++--
 3 files changed, 45 insertions(+), 2 deletions(-)
---
diff --git a/NEWS b/NEWS
index 5ee242e29..de0a8f78c 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,8 @@
 Gnumeric 1.12.48
 
+Andreas:
+       * Add axis title to chart in histogram tool. [#408]
+
 --------------------------------------------------------------------------
 Gnumeric 1.12.47
 
diff --git a/src/tools/ChangeLog b/src/tools/ChangeLog
index fed1b04d3..d92888b26 100644
--- a/src/tools/ChangeLog
+++ b/src/tools/ChangeLog
@@ -1,3 +1,8 @@
+2020-05-09  Andreas J. Guelzow <aguelzow pyrshep ca>
+
+       * analysis-histogram.c (analysis_tool_histogram_engine_run):
+       add axis title to chart
+
 2020-05-09  Morten Welinder <terra gnome org>
 
        * Release 1.12.47
diff --git a/src/tools/analysis-histogram.c b/src/tools/analysis-histogram.c
index 12f1b2d42..30448d3b6 100644
--- a/src/tools/analysis-histogram.c
+++ b/src/tools/analysis-histogram.c
@@ -1,3 +1,4 @@
+/* vm: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
 /*
  * analysis-histogram.c:
  *
@@ -402,14 +403,48 @@ analysis_tool_histogram_engine_run (data_analysis_output_t *dao,
 
                if (info->chart == HISTOGRAM_CHART) {
                        GogObject *axis;
+                       GogObject *label;
+                       GnmExprTop const *label_string;
+                       GOData *data;
                        axis = gog_object_get_child_by_name (GOG_OBJECT (chart), "X-Axis");
                        go_object_set_property (G_OBJECT (axis), "assigned-format-string-XL",
                                                "X-Axis Format", "0.0EE0",
                                                NULL, NULL);
+                       axis = gog_object_get_child_by_name (GOG_OBJECT (chart), "Y-Axis");
+                       label_string = gnm_expr_top_new_constant (value_new_string (_("Frequency Density")));
+                       data = gnm_go_data_scalar_new_expr (dao->sheet, label_string);
+                       label = gog_object_add_by_name (axis, "Label", NULL);
+                       gog_dataset_set_dim (GOG_DATASET (label), 0, data, NULL);
+               } else if (info->chart == COLUMN_CHART) {
+                       GogObject *axis;
+                       GogObject *label;
+                       GnmExprTop const *label_string;
+                       GOData *data;
+                       axis = gog_object_get_child_by_name (GOG_OBJECT (chart), "X-Axis");
+                       go_object_set_property (G_OBJECT (axis), "assigned-format-string-XL",
+                                               "X-Axis Format", "0.0EE0",
+                                               NULL, NULL);
+                       axis = gog_object_get_child_by_name (GOG_OBJECT (chart), "Y-Axis");
+                       label_string = gnm_expr_top_new_constant (value_new_string (_("Frequency")));
+                       data = gnm_go_data_scalar_new_expr (dao->sheet, label_string);
+                       label = gog_object_add_by_name (axis, "Label", NULL);
+                       gog_dataset_set_dim (GOG_DATASET (label), 0, data, NULL);
+               } else if (info->chart == BAR_CHART) {
+                       GogObject *axis;
+                       GogObject *label;
+                       GnmExprTop const *label_string;
+                       GOData *data;
+                       axis = gog_object_get_child_by_name (GOG_OBJECT (chart), "Y-Axis");
+                       go_object_set_property (G_OBJECT (axis), "assigned-format-string-XL",
+                                               "X-Axis Format", "0.0EE0",
+                                               NULL, NULL);
+                       axis = gog_object_get_child_by_name (GOG_OBJECT (chart), "X-Axis");
+                       label_string = gnm_expr_top_new_constant (value_new_string (_("Frequency")));
+                       data = gnm_go_data_scalar_new_expr (dao->sheet, label_string);
+                       label = gog_object_add_by_name (axis, "Label", NULL);
+                       gog_dataset_set_dim (GOG_DATASET (label), 0, data, NULL);
                }
 
-
-
                so = sheet_object_graph_new (graph);
                g_object_unref (graph);
 


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