X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Foutput%2Fcharts%2Fscatterplot-cairo.c;h=17307497c783f7b2c4d5bea00634170d955f05b9;hb=6132656980af2e8527e3e83c8418846ef4c478c7;hp=736d5e2ae7102c210f4022bf89ef6a37c77fd9aa;hpb=961577539cc6e149b30341f673c09cb3cd554272;p=pspp diff --git a/src/output/charts/scatterplot-cairo.c b/src/output/charts/scatterplot-cairo.c index 736d5e2ae7..17307497c7 100644 --- a/src/output/charts/scatterplot-cairo.c +++ b/src/output/charts/scatterplot-cairo.c @@ -28,12 +28,13 @@ #include "gettext.h" #define _(msgid) gettext (msgid) +static const struct xrchart_colour black = {0,0,0}; void -xrchart_draw_scatterplot (const struct chart_item *chart_item, cairo_t *cr, +xrchart_draw_scatterplot (const struct chart *chart, cairo_t *cr, struct xrchart_geometry *geom) { - const struct scatterplot_chart *spc = to_scatterplot_chart (chart_item); + const struct scatterplot_chart *spc = to_scatterplot_chart (chart); struct casereader *data; struct ccase *c; /* While reading the cases, a list with categories of the byvar is build */ @@ -45,13 +46,15 @@ xrchart_draw_scatterplot (const struct chart_item *chart_item, cairo_t *cr, int byvar_width = 0; int i = 0; const struct xrchart_colour *colour; - + if (spc->byvar) byvar_width = var_get_width (spc->byvar); - xrchart_write_xscale (cr, geom, spc->x_min, spc->x_max); - xrchart_write_yscale (cr, geom, spc->y_min, spc->y_max); - xrchart_write_title (cr, geom, _("Scatterplot %s"), chart_item->title); + if (! xrchart_write_xscale (cr, geom, spc->x_min, spc->x_max)) + return; + if (! xrchart_write_yscale (cr, geom, spc->y_min, spc->y_max)) + return; + xrchart_write_title (cr, geom, _("Scatterplot %s"), chart->title); xrchart_write_xlabel (cr, geom, spc->xlabel); xrchart_write_ylabel (cr, geom, spc->ylabel); @@ -87,13 +90,16 @@ xrchart_draw_scatterplot (const struct chart_item *chart_item, cairo_t *cr, i--; } } + colour = &data_colour[i % XRCHART_N_COLOURS]; } - colour = &data_colour[i % XRCHART_N_COLOURS]; + else + colour = &black; + cairo_set_source_rgb (cr, colour->red / 255.0, colour->green / 255.0, colour->blue / 255.0); - + xrchart_datum (cr, geom, 0, case_data_idx (c, SP_IDX_X)->f, case_data_idx (c, SP_IDX_Y)->f);