[GRASS-SVN] r64881 - grass/branches/releasebranch_6_4/display/d.vect.chart
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Mar 17 02:09:45 PDT 2015
Author: mmetz
Date: 2015-03-17 02:09:45 -0700 (Tue, 17 Mar 2015)
New Revision: 64881
Modified:
grass/branches/releasebranch_6_4/display/d.vect.chart/main.c
grass/branches/releasebranch_6_4/display/d.vect.chart/pie.c
Log:
d.vect.chart: backport bugfixes
Modified: grass/branches/releasebranch_6_4/display/d.vect.chart/main.c
===================================================================
--- grass/branches/releasebranch_6_4/display/d.vect.chart/main.c 2015-03-17 08:43:33 UTC (rev 64880)
+++ grass/branches/releasebranch_6_4/display/d.vect.chart/main.c 2015-03-17 09:09:45 UTC (rev 64881)
@@ -195,7 +195,7 @@
colors = (COLOR *) G_malloc(ncols * sizeof(COLOR));
/* Fill max_reference values */
- max_reference = (double *)G_malloc(ncols * sizeof(double));
+ max_reference = NULL;
/* default colors */
j = 0;
@@ -258,6 +258,7 @@
/* should we plot the maximum reference on bar plots? */
if (max_reference_opt->answer != NULL) {
+ max_reference = (double *)G_malloc(ncols * sizeof(double));
/* loop through the given values */
for (i = 0; i < ncols; i++) {
Modified: grass/branches/releasebranch_6_4/display/d.vect.chart/pie.c
===================================================================
--- grass/branches/releasebranch_6_4/display/d.vect.chart/pie.c 2015-03-17 08:43:33 UTC (rev 64880)
+++ grass/branches/releasebranch_6_4/display/d.vect.chart/pie.c 2015-03-17 09:09:45 UTC (rev 64881)
@@ -21,27 +21,33 @@
G_debug(4, "pie(): cx = %f cy = %f", cx, cy);
- Points = Vect_new_line_struct();
-
/* Calc sum */
tot_sum = 0;
for (i = 0; i < ncols; i++)
tot_sum += val[i];
+ if (tot_sum == 0) {
+ return 0; /* nothing to draw */
+ }
+
+ Points = Vect_new_line_struct();
+
step = PI / 180;
r = (D_d_to_u_col(2) - D_d_to_u_col(1)) * size / 2; /* do it better */
/* Draw polygon for each value */
sum = 0;
ang = 0;
for (i = 0; i < ncols; i++) {
+ if (val[i] == 0)
+ continue;
+
sum += val[i];
- if (tot_sum > 0.0)
- end_ang = 2 * PI * sum / tot_sum;
- else
- end_ang = 0;
+
+ end_ang = 2 * PI * sum / tot_sum;
+
Vect_reset_line(Points);
- if (val[0] != tot_sum) /* all in one slice, don't draw line to center */
+ if (val[i] != tot_sum) /* all in one slice, don't draw line to center */
Vect_append_point(Points, cx, cy, 0);
n = (int)ceil((end_ang - ang) / step);
@@ -54,7 +60,7 @@
}
ang = end_ang;
- if (val[0] != tot_sum)
+ if (val[i] != tot_sum)
Vect_append_point(Points, cx, cy, 0);
if (!colors[i].none) {
More information about the grass-commit
mailing list