X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Foutput%2Fcharts%2Fbarchart.c;h=7869d5d6bd4355f71f8e82ee917f43edd95edb19;hb=f3fb5df541147f31335d86850d5f4dd2568c5c72;hp=8e1b63d7ff97b631fe3974f03052e93c4976eba7;hpb=d8749acaf878dccf9e4527c27d06d06eb5e03091;p=pspp
diff --git a/src/output/charts/barchart.c b/src/output/charts/barchart.c
index 8e1b63d7ff..7869d5d6bd 100644
--- a/src/output/charts/barchart.c
+++ b/src/output/charts/barchart.c
@@ -1,20 +1,18 @@
-/* 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
@@ -33,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",
@@ -59,7 +57,7 @@ static const double data1[] =
29,13,
9,4,
3,3,
- 2,0,
+ 2,0,
1,0,
0,
1,1
@@ -71,7 +69,7 @@ static const double data2[] =
45,13,
9,4,
3,43,
- 2,0,
+ 2,0,
1,20,
0,0,
1,1,
@@ -93,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"}
};
@@ -112,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 */
@@ -135,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;
@@ -143,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]);
-
+
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;
@@ -188,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);
@@ -207,7 +205,7 @@ draw_barchart(struct chart *ch, const char *title,
chart_write_title(ch, title);
write_legend(ch);
-
+
}
@@ -224,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,
@@ -250,5 +248,5 @@ write_legend(struct chart *chart)
}
- pl_restorestate_r(chart->lp);
+ pl_restorestate_r(chart->lp);
}