X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Foutput%2Fcharts%2Fscatterplot.c;h=5e8d27155e72606d850d979dfec12bb91c73c1a7;hb=3640237a5fc890a84cb814fbe8bf6fd9299624e4;hp=920bc17367a8e5a2741b46c026f74da4a4acc4c7;hpb=80595f6de2ea8f0b64756d76c7ac3c89a1abbbb8;p=pspp diff --git a/src/output/charts/scatterplot.c b/src/output/charts/scatterplot.c index 920bc17367..5e8d27155e 100644 --- a/src/output/charts/scatterplot.c +++ b/src/output/charts/scatterplot.c @@ -1,5 +1,5 @@ /* 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 @@ -21,29 +21,25 @@ #include #include "data/casereader.h" +#include "data/variable.h" #include "libpspp/cast.h" -#include "output/chart-item-provider.h" +#include "output/chart-provider.h" #include "gl/minmax.h" - -/* Creates a scatterplot - - The caller retains ownership of READER. */ +/* Creates a scatterplot */ struct scatterplot_chart * -scatterplot_create (const struct casereader *reader, - const struct variable *xvar, - const struct variable *yvar, +scatterplot_create (struct casereader *reader, + const char *xlabel, + const char *ylabel, const struct variable *byvar, bool *byvar_overflow, const char *label, double xmin, double xmax, double ymin, double ymax) { - struct scatterplot_chart *spc; - - spc = xzalloc (sizeof *spc); - chart_item_init (&spc->chart_item, &scatterplot_chart_class, label); - spc->data = casereader_clone (reader); + struct scatterplot_chart *spc = XZALLOC (struct scatterplot_chart); + chart_init (&spc->chart, &scatterplot_chart_class, label); + spc->data = reader; spc->y_min = ymin; spc->y_max = ymax; @@ -51,23 +47,28 @@ scatterplot_create (const struct casereader *reader, spc->x_min = xmin; spc->x_max = xmax; - spc->xvar = xvar; - spc->yvar = yvar; - spc->byvar = byvar; + spc->xlabel = xstrdup (xlabel); + spc->ylabel = xstrdup (ylabel); + spc->byvar = byvar != NULL ? var_clone (byvar) : NULL; + spc->byvar_overflow = byvar_overflow; return spc; } static void -scatterplot_chart_destroy (struct chart_item *chart_item) +scatterplot_chart_destroy (struct chart *chart) { - struct scatterplot_chart *spc = to_scatterplot_chart (chart_item); + struct scatterplot_chart *spc = to_scatterplot_chart (chart); casereader_destroy (spc->data); + free (spc->xlabel); + free (spc->ylabel); + if (spc->byvar) + var_unref (spc->byvar); free (spc); } -const struct chart_item_class scatterplot_chart_class = +const struct chart_class scatterplot_chart_class = { scatterplot_chart_destroy };