[goffice] Fixed series elements when skipping negative values in pies.



commit 77b00f87ce27d1c924d9e54462409ecf07d795a5
Author: Jean Brefort <jean brefort normalesup org>
Date:   Sun Nov 8 07:42:39 2009 +0100

    Fixed series elements when skipping negative values in pies.

 ChangeLog                  |    5 +++++
 plugins/plot_pie/gog-pie.c |   14 ++++++++++----
 2 files changed, 15 insertions(+), 4 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index da70d7f..df9d7e8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2009-11-08  Jean Brefort  <jean brefort normalesup org>
+
+	* plugins/plot_pie/gog-pie.c (find_element), (gog_pie_view_render): make
+	points work when negative values are skipped.
+
 2009-11-06  Jean Brefort  <jean brefort normalesup org>
 	* goffice/graph/gog-plot.c (gog_plot_update_cardinality),
 	(gog_plot_foreach_elem): add trend lines to legend. [#383518]
diff --git a/plugins/plot_pie/gog-pie.c b/plugins/plot_pie/gog-pie.c
index 61f955d..677936c 100644
--- a/plugins/plot_pie/gog-pie.c
+++ b/plugins/plot_pie/gog-pie.c
@@ -505,7 +505,9 @@ find_element (GogView *view, double cx, double cy, double x, double y,
 	vals = go_data_get_values ((*series)->base.values[1].data);
 	scale = 1 / (*series)->total;
 	for (*index = 0 ; *index < (*series)->base.num_elements; (*index)++) {
-		len = fabs (vals[*index]) * scale;
+		len = vals[*index] * scale;
+		if (len < 0.)
+			len = pie->show_negatives? -len: 0.;
 		if (go_finite (len) && len > 1e-3) {
 			theta -= len;
 			if (theta < 0)
@@ -820,8 +822,12 @@ gog_pie_view_render (GogView *view, GogViewAllocation const *bbox)
 			len = vals[k] * scale;
 			negative = len < 0;
 			if (negative) {
-				if (mode == GOG_SHOW_NEGS_SKIP)
+				if (mode == GOG_SHOW_NEGS_SKIP) {
+					if ((overrides != NULL) &&
+					    (GOG_SERIES_ELEMENT (overrides->data)->index == k))
+						overrides = overrides->next;
 					continue;
+				}
 				len = -len;
 			}
 			if (!go_finite (len) || len < 1e-3) {
@@ -847,9 +853,9 @@ gog_pie_view_render (GogView *view, GogViewAllocation const *bbox)
 						go_styled_object_get_style (
 							GO_STYLED_OBJECT (gpse)));
 			} else {
-				if (negative && mode == GOG_SHOW_NEGS_WHITE) {printf("white style %p line mode=%u\n",white_style,white_style->line.dash_type);
+				if (negative && mode == GOG_SHOW_NEGS_WHITE)
 					gog_renderer_push_style (view->renderer, white_style);
-				} else if (model->base.vary_style_by_element)
+				else if (model->base.vary_style_by_element)
 					gog_theme_fillin_style (theme, style, GOG_OBJECT (series),
 								model->base.index_num + k, GO_STYLE_FILL);
 			}



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