projects
/
pspp
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
zip-writer: Add functions for writing a member over multiple calls.
[pspp]
/
src
/
output
/
charts
/
scatterplot-cairo.c
diff --git
a/src/output/charts/scatterplot-cairo.c
b/src/output/charts/scatterplot-cairo.c
index b555a120880314a343929948f6579ad2ca76124d..cf62539fab1d5b29e2b65e11a225f2b9bbfba9ed 100644
(file)
--- a/
src/output/charts/scatterplot-cairo.c
+++ b/
src/output/charts/scatterplot-cairo.c
@@
-1,5
+1,5
@@
/* PSPP - a program for statistical analysis.
/* PSPP - a program for statistical analysis.
- Copyright (C) 2014 Free Software Foundation, Inc.
+ Copyright (C) 2014
, 2015
Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@
-28,6
+28,7
@@
#include "gettext.h"
#define _(msgid) gettext (msgid)
#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,
void
xrchart_draw_scatterplot (const struct chart_item *chart_item, cairo_t *cr,
@@
-45,17
+46,17
@@
xrchart_draw_scatterplot (const struct chart_item *chart_item, cairo_t *cr,
int byvar_width = 0;
int i = 0;
const struct xrchart_colour *colour;
int byvar_width = 0;
int i = 0;
const struct xrchart_colour *colour;
-
+
if (spc->byvar)
if (spc->byvar)
- byvar_width = var_get_width(spc->byvar);
+ byvar_width = var_get_width
(spc->byvar);
- xrchart_write_xscale (cr, geom,
- spc->x_min,
- spc->x_max, 5);
-
xrchart_write_yscale (cr, geom, spc->y_min, spc->y_max, 5)
;
+ 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_item->title);
xrchart_write_title (cr, geom, _("Scatterplot %s"), chart_item->title);
- xrchart_write_xlabel (cr, geom,
var_to_string(spc->xvar)
);
- xrchart_write_ylabel (cr, geom,
var_to_string(spc->yvar)
);
+ xrchart_write_xlabel (cr, geom,
spc->xlabel
);
+ xrchart_write_ylabel (cr, geom,
spc->ylabel
);
cairo_save (cr);
data = casereader_clone (spc->data);
cairo_save (cr);
data = casereader_clone (spc->data);
@@
-63,25
+64,25
@@
xrchart_draw_scatterplot (const struct chart_item *chart_item, cairo_t *cr,
{
if (spc->byvar)
{
{
if (spc->byvar)
{
- const union value *val = case_data
(c,spc->byvar
);
- for(i=0;i<n_catvals && !value_equal(&catvals[i],val,byvar_width);i++);
+ const union value *val = case_data
_idx (c,SP_IDX_BY
);
+ for(i=0;i<n_catvals && !value_equal
(&catvals[i],val,byvar_width);i++);
if (i == n_catvals) /* No entry found */
{
if (n_catvals < MAX_PLOT_CATS)
{
struct string label;
if (i == n_catvals) /* No entry found */
{
if (n_catvals < MAX_PLOT_CATS)
{
struct string label;
- ds_init_empty(&label);
- if (var_is_value_missing(spc->byvar,val,MV_ANY))
- ds_put_cstr(&label,"missing");
+ ds_init_empty
(&label);
+ if (var_is_value_missing
(spc->byvar,val,MV_ANY))
+ ds_put_cstr
(&label,"missing");
else
else
- var_append_value_name(spc->byvar,val,&label);
- value_clone(&catvals[n_catvals++],val,byvar_width);
+ var_append_value_name
(spc->byvar,val,&label);
+ value_clone
(&catvals[n_catvals++],val,byvar_width);
geom->n_datasets++;
geom->dataset = xrealloc (geom->dataset,
geom->n_datasets * sizeof (*geom->dataset));
geom->n_datasets++;
geom->dataset = xrealloc (geom->dataset,
geom->n_datasets * sizeof (*geom->dataset));
- geom->dataset[geom->n_datasets - 1] = strdup(ds_cstr(&label));
- ds_destroy(&label);
+ geom->dataset[geom->n_datasets - 1] = strdup
(ds_cstr(&label));
+ ds_destroy
(&label);
}
else /* Use the last plot category */
{
}
else /* Use the last plot category */
{
@@
-89,29
+90,27
@@
xrchart_draw_scatterplot (const struct chart_item *chart_item, cairo_t *cr,
i--;
}
}
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);
cairo_set_source_rgb (cr,
colour->red / 255.0,
colour->green / 255.0,
colour->blue / 255.0);
-
+
xrchart_datum (cr, geom, 0,
xrchart_datum (cr, geom, 0,
- case_data
(c, spc->xvar
)->f,
- case_data
(c, spc->yvar
)->f);
+ case_data
_idx (c, SP_IDX_X
)->f,
+ case_data
_idx (c, SP_IDX_Y
)->f);
}
casereader_destroy (data);
}
casereader_destroy (data);
- cairo_restore(cr);
+ cairo_restore
(cr);
for(i=0;i<n_catvals;i++)
for(i=0;i<n_catvals;i++)
- value_destroy(&catvals[i],byvar_width);
+ value_destroy
(&catvals[i],byvar_width);
if (spc->byvar)
if (spc->byvar)
- xrchart_write_legend(cr, geom);
-
-
-
- // xrchart_line (cr, geom, npp->slope, npp->intercept,
- // npp->y_first, npp->y_last, XRCHART_DIM_Y);
+ xrchart_write_legend (cr, geom);
}
}