1 /* PSPP - a program for statistical analysis.
2 Copyright (C) 2004, 2009 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_PLOT_HIST_H
18 #define OUTPUT_PLOT_HIST_H
20 #include <gsl/gsl_histogram.h>
23 #include "output/chart-item.h"
25 struct histogram_chart
27 struct chart_item chart_item;
28 gsl_histogram *gsl_hist;
35 /* Creates and returns a new chart that depicts a histogram of
36 the data in HIST with the given LABEL. Labels the histogram
37 with each of N, MEAN, and STDDEV that is not SYSMIS. If all
38 three are not SYSMIS and SHOW_NORMAL is true, also draws a
39 normal curve on the histogram. */
40 struct chart_item *histogram_chart_create (const gsl_histogram *,
41 const char *label, double n,
42 double mean, double stddev,
45 /* This boilerplate for histogram_chart, a subclass of chart_item, was
46 autogenerated by mk-class-boilerplate. */
49 #include <libpspp/cast.h>
51 extern const struct chart_item_class histogram_chart_class;
53 /* Returns true if SUPER is a histogram_chart, otherwise false. */
55 is_histogram_chart (const struct chart_item *super)
57 return super->class == &histogram_chart_class;
60 /* Returns SUPER converted to histogram_chart. SUPER must be a histogram_chart, as
61 reported by is_histogram_chart. */
62 static inline struct histogram_chart *
63 to_histogram_chart (const struct chart_item *super)
65 assert (is_histogram_chart (super));
66 return UP_CAST (super, struct histogram_chart, chart_item);
69 /* Returns INSTANCE converted to chart_item. */
70 static inline struct chart_item *
71 histogram_chart_super (const struct histogram_chart *instance)
73 return CONST_CAST (struct chart_item *, &instance->chart_item);
76 /* Increments INSTANCE's reference count and returns INSTANCE. */
77 static inline struct histogram_chart *
78 histogram_chart_ref (const struct histogram_chart *instance)
80 return to_histogram_chart (chart_item_ref (&instance->chart_item));
83 /* Decrements INSTANCE's reference count, then destroys INSTANCE if
84 the reference count is now zero. */
86 histogram_chart_unref (struct histogram_chart *instance)
88 chart_item_unref (&instance->chart_item);
91 /* Returns true if INSTANCE's reference count is greater than 1,
94 histogram_chart_is_shared (const struct histogram_chart *instance)
96 return chart_item_is_shared (&instance->chart_item);
100 histogram_chart_submit (struct histogram_chart *instance)
102 chart_item_submit (&instance->chart_item);
105 #endif /* output/plot-hist.h */