projects
/
pspp
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Smake: Add `check' target for convenience. Add --tests-base=tests to
[pspp]
/
src
/
box-whisker.c
diff --git
a/src/box-whisker.c
b/src/box-whisker.c
index 2600e8aa6c6d5b02b17155a5ada939683f3b3a20..73d0866a2e1cb8d06e5082eab3a78bd933dc2a0f 100644
(file)
--- a/
src/box-whisker.c
+++ b/
src/box-whisker.c
@@
-14,12
+14,13
@@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
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., 5
9 Temple Place - Suite 330
, Boston, MA
- 0211
1-1307
, USA. */
+ Foundation, Inc., 5
1 Franklin Street, Fifth Floor
, Boston, MA
+ 0211
0-1301
, USA. */
#include "chart.h"
#include <math.h>
#include "chart.h"
#include <math.h>
+#include <assert.h>
#include "misc.h"
#include "factor_stats.h"
#include "misc.h"
#include "factor_stats.h"
@@
-74,17
+75,11
@@
boxplot_draw_boxplot(struct chart *ch,
double box_centre,
double box_width,
struct metrics *m,
double box_centre,
double box_width,
struct metrics *m,
- /*
- const double hinge[3],
- struct weighted_value **wvp,
- int n_data,
- */
const char *name)
{
double whisker[2];
int i;
const char *name)
{
double whisker[2];
int i;
-
const double *hinge = m->hinge;
struct weighted_value **wvp = m->wvp;
const int n_data = m->n_data;
const double *hinge = m->hinge;
struct weighted_value **wvp = m->wvp;
const int n_data = m->n_data;
@@
-104,6
+99,12
@@
boxplot_draw_boxplot(struct chart *ch,
const double box_top =
ch->data_bottom + ( hinge[2] - ch->y_min ) * ch->ordinate_scale;
const double box_top =
ch->data_bottom + ( hinge[2] - ch->y_min ) * ch->ordinate_scale;
+ assert(m);
+
+ /* Can't really draw a boxplot if there's no data */
+ if ( n_data == 0 )
+ return ;
+
whisker[1] = hinge[2];
whisker[0] = wvp[0]->v.f;
whisker[1] = hinge[2];
whisker[0] = wvp[0]->v.f;
@@
-117,7
+118,7
@@
boxplot_draw_boxplot(struct chart *ch,
}
}
-
+ {
const double bottom_whisker =
ch->data_bottom + ( whisker[0] - ch->y_min ) * ch->ordinate_scale;
const double bottom_whisker =
ch->data_bottom + ( whisker[0] - ch->y_min ) * ch->ordinate_scale;
@@
-179,6
+180,7
@@
boxplot_draw_boxplot(struct chart *ch,
pl_fline_r(ch->lp,
box_centre, top_whisker,
box_centre, box_top);
pl_fline_r(ch->lp,
box_centre, top_whisker,
box_centre, box_top);
+ }
/* Draw outliers */
for ( i = 0 ; i < n_data ; ++i )
/* Draw outliers */
for ( i = 0 ; i < n_data ; ++i )
@@
-210,6
+212,9
@@
boxplot_draw_yscale(struct chart *ch , double y_max, double y_min)
double y_tick;
double d;
double y_tick;
double d;
+ if ( !ch )
+ return ;
+
ch->y_max = y_max;
ch->y_min = y_min;
ch->y_max = y_max;
ch->y_min = y_min;