[goffice] Fix legend contents for contour plots. [#404]



commit 240148fdbbe9e3f285c6564839190fb0c9e0bbeb
Author: Jean Brefort <jean brefort normalesup org>
Date:   Thu Jun 27 17:11:50 2019 +0200

    Fix legend contents for contour plots. [#404]

 ChangeLog                          |  7 +++++++
 NEWS                               |  1 +
 goffice/graph/gog-axis.c           |  2 +-
 plugins/plot_surface/gog-contour.c | 13 ++++++++++---
 4 files changed, 19 insertions(+), 4 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 87be1a0b..11ce0673 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2019-06-27  Jean Brefort  <jean brefort normalesup org>
+
+       * goffice/graph/gog-axis.c: typo.
+       * plugins/plot_surface/gog-contour.c
+       (gog_contour_plot_build_matrix), (gog_contour_plot_foreach_elem): fix
+       legend contents. [#404]
+
 2019-06-09  Morten Welinder  <terra gnome org>
 
        * goffice/utils/go-format.c (go_format_has_year)
diff --git a/NEWS b/NEWS
index 8e4de3ad..9911b049 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,7 @@ goffice 0.10.46:
 
 Jean:
        * Fix equations edition inside charts.
+       * Fix legend contents for contour plots. [#404]
 
 Morten:
        * Add more functions to inspect formats.
diff --git a/goffice/graph/gog-axis.c b/goffice/graph/gog-axis.c
index 88ab8979..35f71339 100644
--- a/goffice/graph/gog-axis.c
+++ b/goffice/graph/gog-axis.c
@@ -3998,7 +3998,7 @@ gog_axis_get_color_map (GogAxis *axis)
  *
  * Retrieves the #GogColorScale associated to the axis or %NULL.
  * Returns: (transfer none): the color scale used to display the axis colors
- * dor color and pseudo-3d axes.
+ * for color and pseudo-3d axes.
  **/
 GogColorScale *
 gog_axis_get_color_scale (GogAxis *axis)
diff --git a/plugins/plot_surface/gog-contour.c b/plugins/plot_surface/gog-contour.c
index e5fa7b9b..47d4505e 100644
--- a/plugins/plot_surface/gog-contour.c
+++ b/plugins/plot_surface/gog-contour.c
@@ -110,8 +110,11 @@ gog_contour_plot_build_matrix (GogXYZPlot *plot, gboolean *cardinality_changed)
                        else
                                data[i * plot->columns + j] = val;
                }
+       if (gog_series_has_legend (series))
+               max++;
        if ((has_scale && series->num_elements != 1) || series->num_elements != max) {
-               series->num_elements = has_scale? 1: max;
+               series->num_elements = has_scale? 1: max; /* we need to count 1 more
+                                                                                                             
  for the series style */
                *cardinality_changed = TRUE;
        }
        GOG_CONTOUR_PLOT (plot)->max_colors = max;
@@ -143,17 +146,21 @@ gog_contour_plot_foreach_elem  (GogPlot *plot, gboolean only_visible,
        GogAxis *axis = plot->axis[GOG_AXIS_PSEUDO_3D];
        GogAxisColorMap const *map = gog_axis_get_color_map (axis);
        GogAxisTick *zticks;
+       GogSeries *series = GOG_SERIES (plot->series->data);
        double *limits;
        double minimum, maximum, epsilon, scale;
        char const *separator = go_locale_get_decimal ()->str;
 
        /* First get the series name and style */
        style = go_style_dup (go_styled_object_get_style (plot->series->data));
-       if (gog_series_has_legend (GOG_SERIES (plot->series->data)))
+       i = 0;
+       if (gog_series_has_legend (series)) {
                func (0, style,
                          gog_object_get_name (plot->series->data), NULL, data);
+               i = 1;
+       }
 
-       if (gog_axis_get_color_scale (axis)) {
+       if (gog_axis_get_color_scale (axis) || !plot->vary_style_by_element) {
                g_object_unref (style);
                return;
        }


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