eeb3c813be762c201c3bfafc2fd03e096c0a7ca2
[pspp] / src / output / charts / spreadlevel-cairo.c
1 /* PSPP - a program for statistical analysis.
2    Copyright (C) 2012 Free Software Foundation, Inc.
3
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.
8
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.
13
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/>. */
16
17 #include <config.h>
18
19 #include "output/charts/spreadlevel-plot.h"
20
21 #include <math.h>
22
23 #include "output/cairo-chart.h"
24
25 #include "gettext.h"
26 #define _(msgid) gettext (msgid)
27
28 void
29 xrchart_draw_spreadlevel (const struct chart_item *chart_item, cairo_t *cr,
30                     struct xrchart_geometry *geom)
31 {
32   const struct spreadlevel_plot_chart *sl = to_spreadlevel_plot_chart (chart_item);
33   size_t i;
34
35   const char *name = chart_item_get_title (chart_item);
36
37   xrchart_write_title (cr, geom, _("Spread vs. Level Plot of %s"), name);
38   xrchart_write_xlabel (cr, geom, _("Level"));
39   xrchart_write_ylabel (cr, geom, _("Spread"));
40   
41
42   xrchart_write_xscale (cr, geom, sl->x_lower, sl->x_upper, 5);
43   xrchart_write_yscale (cr, geom, sl->y_lower, sl->y_upper, 5);
44
45   for (i = 0 ; i < sl->n_data; ++i)
46     {
47       xrchart_datum (cr, geom, 0, sl->data[i].x, sl->data[i].y);
48     }
49 }