X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fplot-hist.c;h=15578879e1eba6fe9679225e15cd67565e53c23e;hb=1f8dd363d6c20d07fcca14cb948018465fa5ed8b;hp=ebfcd3f107e6984a0a929053000600a6525bb2a9;hpb=2c4c4a789e9c23478bce195d2ed98bab6064dfc1;p=pspp-builds.git diff --git a/src/plot-hist.c b/src/plot-hist.c index ebfcd3f1..15578879 100644 --- a/src/plot-hist.c +++ b/src/plot-hist.c @@ -14,8 +14,8 @@ 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., 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. */ /* If you add/modify any public symbols in this file, don't forget to change the stubs in dummy-chart.c */ @@ -28,17 +28,21 @@ #include #include #include - #include "hash.h" - #include "var.h" #include "chart.h" +#include "gettext.h" +#define _(msgid) gettext (msgid) + /* Write the legend of the chart */ void histogram_write_legend(struct chart *ch, const struct normal_curve *norm) { char buf[100]; + if ( !ch ) + return ; + pl_savestate_r(ch->lp); sprintf(buf,"N = %.2f",norm->N); @@ -62,41 +66,46 @@ static void hist_draw_bar(struct chart *ch, const gsl_histogram *hist, int bar); static void hist_draw_bar(struct chart *ch, const gsl_histogram *hist, int bar) { - double upper; - double lower; - double height; + if ( !ch ) + return ; + - const size_t bins = gsl_histogram_bins(hist); - const double x_pos = (ch->data_right - ch->data_left) * bar / (double) bins ; - const double width = (ch->data_right - ch->data_left) / (double) bins ; + { + double upper; + double lower; + double height; + const size_t bins = gsl_histogram_bins(hist); + const double x_pos = (ch->data_right - ch->data_left) * bar / (double) bins ; + const double width = (ch->data_right - ch->data_left) / (double) bins ; - assert ( 0 == gsl_histogram_get_range(hist, bar, &lower, &upper)); - assert( upper >= lower); + assert ( 0 == gsl_histogram_get_range(hist, bar, &lower, &upper)); - height = gsl_histogram_get(hist, bar) * - (ch->data_top - ch->data_bottom) / gsl_histogram_max_val(hist); + assert( upper >= lower); - pl_savestate_r(ch->lp); - pl_move_r(ch->lp,ch->data_left, ch->data_bottom); - pl_fillcolorname_r(ch->lp, ch->fill_colour); - pl_filltype_r(ch->lp,1); + height = gsl_histogram_get(hist, bar) * + (ch->data_top - ch->data_bottom) / gsl_histogram_max_val(hist); + pl_savestate_r(ch->lp); + pl_move_r(ch->lp,ch->data_left, ch->data_bottom); + pl_fillcolorname_r(ch->lp, ch->fill_colour); + pl_filltype_r(ch->lp,1); - pl_fboxrel_r(ch->lp, - x_pos, 0, - x_pos + width, height); - pl_restorestate_r(ch->lp); + pl_fboxrel_r(ch->lp, + x_pos, 0, + x_pos + width, height); - { - char buf[5]; - snprintf(buf,5,"%g",(upper + lower) / 2.0); - draw_tick(ch, TICK_ABSCISSA, - x_pos + width / 2.0, buf); - } + pl_restorestate_r(ch->lp); + { + char buf[5]; + snprintf(buf,5,"%g",(upper + lower) / 2.0); + draw_tick(ch, TICK_ABSCISSA, + x_pos + width / 2.0, buf); + } + } }