1 /* PSPP - a program for statistical analysis.
2 Copyright (C) 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_CAIRO_CHART_H
18 #define OUTPUT_CAIRO_CHART_H 1
20 #include <cairo/cairo.h>
23 #include "libpspp/compiler.h"
44 /* The geometry of a chart. */
45 struct xrchart_geometry
47 /* Bottom of the abscissa segment */
50 /* Left of the ordinate segment */
61 /* Default font size for the plot. */
64 struct xrchart_colour fill_colour;
66 /* Stuff particular to cartesians and boxplots. */
67 struct xrchart_axis axis[2];
69 /* True iff a path is currently being drawn */
73 void xrchart_geometry_init (cairo_t *, struct xrchart_geometry *,
74 double width, double length);
75 void xrchart_geometry_free (cairo_t *, struct xrchart_geometry *);
77 #define XRCHART_N_COLOURS 9
78 extern const struct xrchart_colour data_colour[];
88 XRMARKER_CIRCLE, /* Hollow circle. */
89 XRMARKER_ASTERISK, /* Asterisk (*). */
90 XRMARKER_SQUARE /* Hollow square. */
93 void xrchart_draw_marker (cairo_t *, double x, double y, enum xrmarker_type,
96 void xrchart_label (cairo_t *, int horz_justify, int vert_justify,
97 double font_size, const char *);
99 /* Draw a tick mark at position
100 If label is non zero, then print it at the tick mark
102 void draw_tick (cairo_t *, const struct xrchart_geometry *,
103 enum tick_orientation orientation, double position,
104 const char *label, ...)
105 PRINTF_FORMAT (5, 6);
108 /* Write the title on a chart*/
109 void xrchart_write_title (cairo_t *, const struct xrchart_geometry *,
110 const char *title, ...)
111 PRINTF_FORMAT (3, 4);
113 /* Set the scale for the abscissa */
114 void xrchart_write_xscale (cairo_t *, struct xrchart_geometry *,
115 double min, double max, int ticks);
118 /* Set the scale for the ordinate */
119 void xrchart_write_yscale (cairo_t *, struct xrchart_geometry *,
120 double smin, double smax, int ticks);
122 void xrchart_write_xlabel (cairo_t *, const struct xrchart_geometry *,
125 /* Write the ordinate label */
126 void xrchart_write_ylabel (cairo_t *, const struct xrchart_geometry *,
129 void xrchart_write_legend (cairo_t *, const struct xrchart_geometry *);
137 void xrchart_vector_start (cairo_t *, struct xrchart_geometry *,
139 void xrchart_vector_end (cairo_t *, struct xrchart_geometry *);
140 void xrchart_vector (cairo_t *, struct xrchart_geometry *, double x, double y);
142 /* Plot a data point */
143 void xrchart_datum (cairo_t *, const struct xrchart_geometry *,
144 int dataset UNUSED, double x, double y);
146 /* Draw a line with slope SLOPE and intercept INTERCEPT.
147 between the points limit1 and limit2.
148 If lim_dim is XRCHART_DIM_Y then the limit{1,2} are on the
149 y axis otherwise the x axis
151 void xrchart_line (cairo_t *, const struct xrchart_geometry *,
152 double slope, double intercept,
153 double limit1, double limit2, enum xrchart_dim lim_dim);
155 /* Drawing various kinds of charts. */
156 void xrchart_draw_boxplot (const struct chart_item *, cairo_t *,
157 struct xrchart_geometry *);
158 void xrchart_draw_roc (const struct chart_item *, cairo_t *,
159 struct xrchart_geometry *);
160 void xrchart_draw_piechart (const struct chart_item *, cairo_t *,
161 struct xrchart_geometry *);
162 void xrchart_draw_histogram (const struct chart_item *, cairo_t *,
163 struct xrchart_geometry *);
164 void xrchart_draw_np_plot (const struct chart_item *, cairo_t *,
165 struct xrchart_geometry *);
166 void xrchart_draw_scree (const struct chart_item *, cairo_t *,
167 struct xrchart_geometry *);
168 void xrchart_draw_spreadlevel (const struct chart_item *, cairo_t *,
169 struct xrchart_geometry *);
172 #endif /* output/cairo-chart.h */