1 /* PSPP - a program for statistical analysis.
2 Copyright (C) 2004, 2009, 2011 Free Software Foundation, Inc.
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
17 #ifndef OUTPUT_CHARTS_BOXPLOT_H
18 #define OUTPUT_CHARTS_BOXPLOT_H 1
21 #include "output/chart-item.h"
23 /* Box-whiskers plot. */
26 struct chart_item chart_item;
29 struct boxplot_box *boxes;
30 size_t n_boxes, boxes_allocated;
32 /* Derived from data and convenient for plotting. */
33 double y_min; /* Minimum Y coordinate of extremum. */
34 double y_max; /* Maximum Y coordinate of extremum. */
37 /* One box within a box-whiskers plot. */
40 struct box_whisker *bw;
41 char *label; /* Variable name or factor label. */
44 struct boxplot *boxplot_create (double y_min, double y_max, const char *title);
45 void boxplot_add_box (struct boxplot *,
46 struct box_whisker *, const char *label);
48 /* This boilerplate for boxplot, a subclass of chart_item, was
49 autogenerated by mk-class-boilerplate. */
52 #include "libpspp/cast.h"
54 extern const struct chart_item_class boxplot_class;
56 /* Returns true if SUPER is a boxplot, otherwise false. */
58 is_boxplot (const struct chart_item *super)
60 return super->class == &boxplot_class;
63 /* Returns SUPER converted to boxplot. SUPER must be a boxplot, as
64 reported by is_boxplot. */
65 static inline struct boxplot *
66 to_boxplot (const struct chart_item *super)
68 assert (is_boxplot (super));
69 return UP_CAST (super, struct boxplot, chart_item);
72 /* Returns INSTANCE converted to chart_item. */
73 static inline struct chart_item *
74 boxplot_super (const struct boxplot *instance)
76 return CONST_CAST (struct chart_item *, &instance->chart_item);
79 /* Increments INSTANCE's reference count and returns INSTANCE. */
80 static inline struct boxplot *
81 boxplot_ref (const struct boxplot *instance)
83 return to_boxplot (chart_item_ref (&instance->chart_item));
86 /* Decrements INSTANCE's reference count, then destroys INSTANCE if
87 the reference count is now zero. */
89 boxplot_unref (struct boxplot *instance)
91 chart_item_unref (&instance->chart_item);
94 /* Returns true if INSTANCE's reference count is greater than 1,
97 boxplot_is_shared (const struct boxplot *instance)
99 return chart_item_is_shared (&instance->chart_item);
103 boxplot_submit (struct boxplot *instance)
105 chart_item_submit (&instance->chart_item);
108 #endif /* output/charts/boxplot.h */