X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=src%2Fcartesian.c;h=22201e4e4e4daa3c6caf8f2f805aa243abb5382b;hb=ff2389320fc25c3598a2fa75ea30f50f260b3ba6;hp=a2e9fbff39b2519828bebeee4e40ad5c2c0496be;hpb=b016884ff112ca57e89f9d0298eb70079fece20d;p=pspp diff --git a/src/cartesian.c b/src/cartesian.c index a2e9fbff39..22201e4e4e 100644 --- a/src/cartesian.c +++ b/src/cartesian.c @@ -53,6 +53,8 @@ write_legend(struct chart *chart, const char *heading, int n); void chart_write_xlabel(struct chart *ch, const char *label) { + if ( ! ch ) + return ; pl_savestate_r(ch->lp); @@ -63,50 +65,15 @@ chart_write_xlabel(struct chart *ch, const char *label) } -/* Set the scale for the abscissa */ -void -chart_write_xscale(struct chart *ch, double min, double max, double tick) -{ - double x; - - ch->x_max = ceil( max / tick ) * tick ; - ch->x_min = floor ( min / tick ) * tick ; - - ch->abscissa_scale = fabs(ch->data_right - ch->data_left) / - fabs(ch->x_max - ch->x_min); - - for(x = ch->x_min ; x <= ch->x_max; x += tick ) - draw_tick (ch, TICK_ABSCISSA, (x - ch->x_min) * ch->abscissa_scale, "%g", x); - -} - - -/* Set the scale for the ordinate */ -void -chart_write_yscale(struct chart *ch, double min, double max, double tick) -{ - double y; - - ch->y_max = ceil( max / tick ) * tick ; - ch->y_min = floor ( min / tick ) * tick ; - - ch->ordinate_scale = - fabs(ch->data_top - ch->data_bottom) / fabs(ch->y_max - ch->y_min) ; - - for(y = ch->y_min ; y <= ch->y_max; y += tick ) - { - draw_tick (ch, TICK_ORDINATE, - (y - ch->y_min) * ch->ordinate_scale, "%g", y); - } - -} - /* Write the ordinate label */ void chart_write_ylabel(struct chart *ch, const char *label) { + if ( ! ch ) + return ; + pl_savestate_r(ch->lp); pl_move_r(ch->lp, ch->data_bottom, ch->ordinate_right); @@ -124,6 +91,10 @@ write_legend(struct chart *chart, const char *heading, { int ds; + if ( ! chart ) + return ; + + pl_savestate_r(chart->lp); pl_filltype_r(chart->lp,1); @@ -162,13 +133,18 @@ write_legend(struct chart *chart, const char *heading, void chart_datum(struct chart *ch, int dataset UNUSED, double x, double y) { + + if ( ! ch ) + return ; + + + const double x_pos = (x - ch->x_min) * ch->abscissa_scale + ch->data_left ; const double y_pos = (y - ch->y_min) * ch->ordinate_scale + ch->data_bottom ; - pl_savestate_r(ch->lp); pl_fmarker_r(ch->lp, x_pos, y_pos, 6, 15); @@ -189,6 +165,10 @@ chart_line(struct chart *ch, double slope, double intercept, double x1, y1; double x2, y2 ; + if ( ! ch ) + return ; + + if ( lim_dim == CHART_DIM_Y ) { x1 = ( limit1 - intercept ) / slope ;