1 /* PSPP - a program for statistical analysis.
2 Copyright (C) 2014, 2015 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_SCATTERPLOT_H
18 #define OUTPUT_CHARTS_SCATTERPLOT_H 1
20 #include "output/chart-item.h"
22 /* Indices for the scatterplot_proto members */
25 SP_IDX_X, /* x value */
26 SP_IDX_Y, /* y value */
27 SP_IDX_BY, /* graph category for xy plot */
31 struct scatterplot_chart
33 struct chart_item chart_item;
34 struct casereader *data;
35 struct variable *byvar;
41 /* If the number of distinct values of byvar */
42 /* exceeds a certain limit, the warning flag */
43 /* is activated after the chart is drawn */
47 struct scatterplot_chart *
48 scatterplot_create (struct casereader *,
51 const struct variable *,
54 double xmin, double xmax, double ymin, double ymax);
56 /* This boilerplate for scatterplot_chart, a subclass of chart_item, was
57 autogenerated by mk-class-boilerplate. */
60 #include "libpspp/cast.h"
62 extern const struct chart_item_class scatterplot_chart_class;
64 /* Returns true if SUPER is a scatterplot_chart, otherwise false. */
66 is_scatterplot_chart (const struct chart_item *super)
68 return super->class == &scatterplot_chart_class;
71 /* Returns SUPER converted to scatterplot_chart. SUPER must be a scatterplot_chart, as
72 reported by is_scatterplot_chart. */
73 static inline struct scatterplot_chart *
74 to_scatterplot_chart (const struct chart_item *super)
76 assert (is_scatterplot_chart (super));
77 return UP_CAST (super, struct scatterplot_chart, chart_item);
80 /* Returns INSTANCE converted to chart_item. */
81 static inline struct chart_item *
82 scatterplot_chart_super (const struct scatterplot_chart *instance)
84 return CONST_CAST (struct chart_item *, &instance->chart_item);
87 /* Increments INSTANCE's reference count and returns INSTANCE. */
88 static inline struct scatterplot_chart *
89 scatterplot_chart_ref (const struct scatterplot_chart *instance)
91 return to_scatterplot_chart (chart_item_ref (&instance->chart_item));
94 /* Decrements INSTANCE's reference count, then destroys INSTANCE if
95 the reference count is now zero. */
97 scatterplot_chart_unref (struct scatterplot_chart *instance)
99 chart_item_unref (&instance->chart_item);
102 /* Returns true if INSTANCE's reference count is greater than 1,
105 scatterplot_chart_is_shared (const struct scatterplot_chart *instance)
107 return chart_item_is_shared (&instance->chart_item);
111 scatterplot_chart_submit (struct scatterplot_chart *instance)
113 chart_item_submit (&instance->chart_item);
116 #endif /* output/charts/scatterplot.h */