Преглед изворни кода

d.vect.chart: bug fixes

git-svn-id: https://svn.osgeo.org/grass/grass/branches/releasebranch_7_0@64861 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Metz пре 10 година
родитељ
комит
92ec838b20
2 измењених фајлова са 10 додато и 7 уклоњено
  1. 2 1
      display/d.vect.chart/main.c
  2. 8 6
      display/d.vect.chart/pie.c

+ 2 - 1
display/d.vect.chart/main.c

@@ -189,7 +189,7 @@ int main(int argc, char **argv)
     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;
@@ -247,6 +247,7 @@ int main(int argc, char **argv)
     
     /* 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++) {

+ 8 - 6
display/d.vect.chart/pie.c

@@ -32,14 +32,16 @@ pie(double cx, double cy, int size, double *val, int ncols, COLOR * ocolor,
     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);
@@ -52,7 +54,7 @@ pie(double cx, double cy, int size, double *val, int ncols, COLOR * ocolor,
 	}
 	ang = end_ang;
 
-	if (val[0] != tot_sum)
+	if (val[i] != tot_sum)    /* all in one slice, don't draw line to center */
 	    Vect_append_point(Points, cx, cy, 0);
 
 	if (!colors[i].none) {