You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- 02111-1307, USA. */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA. */
/*
TODO:
#include "vfm.h"
#include "settings.h"
#include "chart.h"
+
+#include "gettext.h"
+#define _(msgid) gettext (msgid)
+#define N_(msgid) msgid
+
/* (headers) */
#include "debug-print.h"
static void do_piechart(const struct variable *var,
const struct freq_tab *frq_tab);
-void freq_tab_to_hist(const struct freq_tab *ft, gsl_histogram *hist);
+gsl_histogram *
+freq_tab_to_hist(const struct freq_tab *ft, const struct variable *var);
+
\f
/* Parser and outline. */
dump_statistics (v, !dumped_freq_tab);
+
if ( chart == GFT_HIST)
{
double d[frq_n_stats];
struct normal_curve norm;
+ gsl_histogram *hist ;
- gsl_histogram *hist = gsl_histogram_alloc(7);
- norm.N = vf->tab.total_cases;
+ norm.N = vf->tab.valid_cases;
calc_stats(v,d);
norm.mean = d[frq_mean];
norm.stddev = d[frq_stddev];
- freq_tab_to_hist(ft, hist);
+ hist = freq_tab_to_hist(ft,v);
histogram_plot(hist, var_to_string(v), &norm, normal);
}
+
cleanup_freq_tab (v);
}
const struct freq *f = f_;
struct variable *v = v_;
- return !is_missing (&f->v, v);
+ return !mv_is_value_missing (&v->miss, &f->v);
}
/* Summarizes the frequency table data for variable V. */
hsh_compare_func *compare;
struct freq_tab *ft;
size_t count;
- void **data;
+ void *const *data;
struct freq *freqs, *f;
size_t i;
{
nl = ml = 0;
dl = NULL;
- while (token == T_NUM)
+ while (lex_integer ())
{
if (nl >= ml)
{
}
-
-/* Populate a gsl_histogram from a freq_tab */
-void
-freq_tab_to_hist(const struct freq_tab *ft, gsl_histogram *hist)
+/* Create a gsl_histogram from a freq_tab */
+gsl_histogram *
+freq_tab_to_hist(const struct freq_tab *ft, const struct variable *var)
{
int i;
double x_min = DBL_MAX;
double x_max = -DBL_MAX;
-
+
+ gsl_histogram *hist;
+ const double bins = 11;
+
struct hsh_iterator hi;
struct hsh_table *fh = ft->data;
struct freq *frq;
- gsl_histogram_reset(hist);
-
/* Find out the extremes of the x value */
-
- for ( frq = hsh_first(fh, &hi);
- frq != 0;
- frq = hsh_next(fh, &hi) )
+ for ( frq = hsh_first(fh, &hi); frq != 0; frq = hsh_next(fh, &hi) )
{
+ if ( mv_is_value_missing(&var->miss, &frq->v))
+ continue;
+
if ( frq->v.f < x_min ) x_min = frq->v.f ;
if ( frq->v.f > x_max ) x_max = frq->v.f ;
}
-
- gsl_histogram_set_ranges_uniform(hist, x_min, x_max);
+ hist = histogram_create(bins, x_min, x_max);
for( i = 0 ; i < ft->n_valid ; ++i )
{
gsl_histogram_accumulate(hist, frq->v.f, frq->c);
}
+ return hist;
}
+
static struct slice *
freq_tab_to_slice_array(const struct freq_tab *frq_tab,
const struct variable *var,
slices[i].label = value_to_string(&frq->v, var);
slices[i].magnetude = frq->c;
-
}
-
return slices;
}
+
static void
do_piechart(const struct variable *var, const struct freq_tab *frq_tab)
{
piechart_plot(var_to_string(var), slices, n_slices);
free(slices);
-
}
-
/*
Local Variables:
mode: c