X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=src%2Foutput%2Fcharts%2Fbarchart.c;h=88a1d741ddf9199f08404d49096de62dada0a373;hb=ed0dda01c61c6b086e47f64302b75da5df97db87;hp=13ea3dc2f854346a208681b09c0a8870b94e2b46;hpb=164d1274fcb70c54897f2a03fc7c27152ed4821a;p=pspp
diff --git a/src/output/charts/barchart.c b/src/output/charts/barchart.c
index 13ea3dc2f8..88a1d741dd 100644
--- a/src/output/charts/barchart.c
+++ b/src/output/charts/barchart.c
@@ -1,22 +1,22 @@
-/* PSPP - computes sample statistics.
+/* PSPP - a program for statistical analysis.
Copyright (C) 2004 Free Software Foundation, Inc.
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- 02110-1301, USA. */
+ along with this program. If not, see . */
+#include
+
#include
#include
#include
@@ -31,7 +31,7 @@
static const double x_min = 0;
static const double x_max = 15.0;
-static const char *cat_labels[] =
+static const char *cat_labels[] =
{
"Age",
"Intelligence",
@@ -57,7 +57,7 @@ static const double data1[] =
29,13,
9,4,
3,3,
- 2,0,
+ 2,0,
1,0,
0,
1,1
@@ -69,7 +69,7 @@ static const double data2[] =
45,13,
9,4,
3,43,
- 2,0,
+ 2,0,
1,20,
0,0,
1,1,
@@ -91,11 +91,11 @@ struct subcat {
const char *label;
};
-static const struct subcat sub_catagory[SUB_CATAGORIES] =
+static const struct subcat sub_catagory[SUB_CATAGORIES] =
{
{data1, "male"},
{data2, "female"},
- {data3, "47xxy"}
+ {data3, "47xxy"}
};
@@ -110,20 +110,20 @@ static void write_legend(struct chart *chart) ;
void
-draw_barchart(struct chart *ch, const char *title,
+draw_barchart(struct chart *ch, const char *title,
const char *xlabel, const char *ylabel, enum bar_opts opt)
{
double d;
int i;
double interval_size = fabs(ch->data_right - ch->data_left) / ( CATAGORIES );
-
+
double bar_width = interval_size / 1.1 ;
double ordinate_scale = fabs(ch->data_top - ch->data_bottom) /
- fabs(y_max - y_min) ;
+ fabs(y_max - y_min) ;
- if ( opt != BAR_STACKED )
+ if ( opt != BAR_STACKED )
bar_width /= SUB_CATAGORIES;
/* Move to data bottom-left */
@@ -133,7 +133,7 @@ draw_barchart(struct chart *ch, const char *title,
pl_filltype_r(ch->lp,1);
/* Draw the data */
- for (i = 0 ; i < CATAGORIES ; ++i )
+ for (i = 0 ; i < CATAGORIES ; ++i )
{
int sc;
double ystart=0.0;
@@ -141,33 +141,33 @@ draw_barchart(struct chart *ch, const char *title,
pl_savestate_r(ch->lp);
- draw_tick (ch, TICK_ABSCISSA, x + (interval_size/2 ),
+ draw_tick (ch, TICK_ABSCISSA, x + (interval_size/2 ),
cat_labels[i]);
- for(sc = 0 ; sc < SUB_CATAGORIES ; ++sc )
+ for(sc = 0 ; sc < SUB_CATAGORIES ; ++sc )
{
-
+
pl_savestate_r(ch->lp);
- pl_fillcolorname_r(ch->lp,data_colour[sc]);
-
+ pl_fillcolorname_r(ch->lp,data_colour[sc % N_CHART_COLOURS]);
+
switch ( opt )
{
case BAR_GROUPED:
- pl_fboxrel_r(ch->lp,
+ pl_fboxrel_r(ch->lp,
x + (sc * bar_width ), 0,
- x + (sc + 1) * bar_width,
+ x + (sc + 1) * bar_width,
sub_catagory[sc].data[i] * ordinate_scale );
break;
-
+
case BAR_STACKED:
- pl_fboxrel_r(ch->lp,
- x, ystart,
- x + bar_width,
+ pl_fboxrel_r(ch->lp,
+ x, ystart,
+ x + bar_width,
ystart + sub_catagory[sc].data[i] * ordinate_scale );
- ystart += sub_catagory[sc].data[i] * ordinate_scale ;
+ ystart += sub_catagory[sc].data[i] * ordinate_scale ;
break;
@@ -186,14 +186,14 @@ draw_barchart(struct chart *ch, const char *title,
draw_tick (ch, TICK_ORDINATE,
(d - y_min ) * ordinate_scale, "%g", d);
-
+
}
/* Write the abscissa label */
pl_move_r(ch->lp,ch->data_left, ch->abscissa_top);
pl_alabel_r(ch->lp,0,'t',xlabel);
-
+
/* Write the ordinate label */
pl_savestate_r(ch->lp);
pl_move_r(ch->lp,ch->data_bottom, ch->ordinate_right);
@@ -205,7 +205,7 @@ draw_barchart(struct chart *ch, const char *title,
chart_write_title(ch, title);
write_legend(ch);
-
+
}
@@ -222,23 +222,23 @@ write_legend(struct chart *chart)
pl_filltype_r(chart->lp,1);
- pl_move_r(chart->lp, chart->legend_left,
+ pl_move_r(chart->lp, chart->legend_left,
chart->data_bottom + chart->font_size * SUB_CATAGORIES * 1.5);
pl_alabel_r(chart->lp,0,'b',subcat_name);
- for (sc = 0 ; sc < SUB_CATAGORIES ; ++sc )
+ for (sc = 0 ; sc < SUB_CATAGORIES ; ++sc )
{
pl_fmove_r(chart->lp,
chart->legend_left,
chart->data_bottom + chart->font_size * sc * 1.5);
- pl_savestate_r(chart->lp);
+ pl_savestate_r(chart->lp);
pl_fillcolorname_r(chart->lp,data_colour[sc]);
pl_fboxrel_r (chart->lp,
0,0,
chart->font_size, chart->font_size);
- pl_restorestate_r(chart->lp);
+ pl_restorestate_r(chart->lp);
pl_fmove_r(chart->lp,
chart->legend_left + chart->font_size * 1.5,
@@ -248,5 +248,5 @@ write_legend(struct chart *chart)
}
- pl_restorestate_r(chart->lp);
+ pl_restorestate_r(chart->lp);
}