projects
/
pspp
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
output-item: Collapse the inheritance hierarchy into a single struct.
[pspp]
/
src
/
output
/
charts
/
barchart-cairo.c
diff --git
a/src/output/charts/barchart-cairo.c
b/src/output/charts/barchart-cairo.c
index 397715ff386d38884ce4ca9838ec39a1bb648c74..4663471e566e9c81b22ac0fb9d3bc3435d4e5a39 100644
(file)
--- a/
src/output/charts/barchart-cairo.c
+++ b/
src/output/charts/barchart-cairo.c
@@
-1,5
+1,5
@@
/* PSPP - a program for statistical analysis.
/* PSPP - a program for statistical analysis.
- Copyright (C) 2015 Free Software Foundation, Inc.
+ Copyright (C) 2015
, 2016
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
@@
-43,10
+43,10
@@
abscissa_label (const struct barchart *bc, cairo_t *cr,
size_t hash = value_hash (prev, bc->widths[0], 0);
HMAP_FOR_EACH_WITH_HASH (foo, struct category, node, hash, &bc->primaries)
{
size_t hash = value_hash (prev, bc->widths[0], 0);
HMAP_FOR_EACH_WITH_HASH (foo, struct category, node, hash, &bc->primaries)
{
- if (value_equal (&foo->val, prev, bc->widths[0]))
+ if (value_equal (&foo->val, prev, bc->widths[0]))
break;
}
break;
}
-
+
draw_tick (cr, geom, SCALE_ABSCISSA, false,
x_pos - (width * n_last_cat) / 2.0,
"%s", ds_cstr (&foo->label));
draw_tick (cr, geom, SCALE_ABSCISSA, false,
x_pos - (width * n_last_cat) / 2.0,
"%s", ds_cstr (&foo->label));
@@
-56,18
+56,20
@@
abscissa_label (const struct barchart *bc, cairo_t *cr,
void
void
-xrchart_draw_barchart (const struct chart
_item *chart_item
, cairo_t *cr,
+xrchart_draw_barchart (const struct chart
*chart
, cairo_t *cr,
struct xrchart_geometry *geom)
{
struct xrchart_geometry *geom)
{
- struct barchart *bc = to_barchart (chart
_item
);
+ struct barchart *bc = to_barchart (chart);
int i;
xrchart_write_title (cr, geom, _("Bar Chart"));
xrchart_write_ylabel (cr, geom, bc->ylabel);
int i;
xrchart_write_title (cr, geom, _("Bar Chart"));
xrchart_write_ylabel (cr, geom, bc->ylabel);
- xrchart_write_xlabel (cr, geom, chart_
item_get_title (chart_item
));
+ xrchart_write_xlabel (cr, geom, chart_
get_title (chart
));
- xrchart_write_yscale (cr, geom, 0, bc->largest);
+ if (! xrchart_write_yscale (cr, geom, 0,
+ bc->percent ? bc->largest * 100.0 / bc->total_count : bc->largest))
+ return;
const double abscale = geom->axis[SCALE_ABSCISSA].data_max - geom->axis[SCALE_ABSCISSA].data_min;
const double width = abscale / (double) (bc->n_nzcats + bc->n_pcats);
const double abscale = geom->axis[SCALE_ABSCISSA].data_max - geom->axis[SCALE_ABSCISSA].data_min;
const double width = abscale / (double) (bc->n_nzcats + bc->n_pcats);
@@
-79,7
+81,7
@@
xrchart_draw_barchart (const struct chart_item *chart_item, cairo_t *cr,
{
const int blob_size = 13;
const int height = blob_size * (hmap_count (&bc->secondaries) * 2);
{
const int blob_size = 13;
const int height = blob_size * (hmap_count (&bc->secondaries) * 2);
-
+
cairo_rectangle (cr,
geom->axis[SCALE_ABSCISSA].data_max + 10,
geom->axis[SCALE_ORDINATE].data_max - height,
cairo_rectangle (cr,
geom->axis[SCALE_ABSCISSA].data_max + 10,
geom->axis[SCALE_ORDINATE].data_max - height,
@@
-92,10
+94,10
@@
xrchart_draw_barchart (const struct chart_item *chart_item, cairo_t *cr,
{
const struct category *foo = bc->ss[i];
{
const struct category *foo = bc->ss[i];
- cairo_move_to (cr,
+ cairo_move_to (cr,
geom->axis[SCALE_ABSCISSA].data_max + (1.5 * blob_size) + 20,
geom->axis[SCALE_ORDINATE].data_max - ypos);
geom->axis[SCALE_ABSCISSA].data_max + (1.5 * blob_size) + 20,
geom->axis[SCALE_ORDINATE].data_max - ypos);
-
+
xrchart_label (cr, 'l', 'b', geom->font_size, ds_cstr (&foo->label));
cairo_rectangle (cr,
xrchart_label (cr, 'l', 'b', geom->font_size, ds_cstr (&foo->label));
cairo_rectangle (cr,
@@
-111,7
+113,7
@@
xrchart_draw_barchart (const struct chart_item *chart_item, cairo_t *cr,
cairo_fill_preserve (cr);
cairo_restore (cr);
cairo_fill_preserve (cr);
cairo_restore (cr);
-
+
cairo_stroke (cr);
ypos += blob_size * 2;
cairo_stroke (cr);
ypos += blob_size * 2;
@@
-122,6
+124,8
@@
xrchart_draw_barchart (const struct chart_item *chart_item, cairo_t *cr,
for (i = 0; i < bc->n_nzcats; i++)
{
double height = geom->axis[SCALE_ORDINATE].scale * bc->cats[i]->count;
for (i = 0; i < bc->n_nzcats; i++)
{
double height = geom->axis[SCALE_ORDINATE].scale * bc->cats[i]->count;
+ if (bc->percent)
+ height *= 100.0 / bc->total_count ;
if (prev && !value_equal (prev, &bc->cats[i]->values[0], bc->widths[0]))
{
if (prev && !value_equal (prev, &bc->cats[i]->values[0], bc->widths[0]))
{