From 347cb51593b323a7982c0553aef148c64aeff847 Mon Sep 17 00:00:00 2001 From: Brian Matherly Date: Mon, 18 Feb 2008 04:49:54 +0000 Subject: [PATCH] Patch from Peter Landgren fixes: 0001756: Very strange results with statistics report. 0001760: Pie charts are clipped if paper in landscape mode. svn: r10045 --- ChangeLog | 5 +++++ src/plugins/StatisticsChart.py | 26 ++++++++++++++++++-------- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index fc29b4192..9bc21a2aa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2008-02-17 Peter Landgren + * src/plugins/StatisticsChart.py: + 0001756: Very strange results with statistics report. + 0001760: Pie charts are clipped if paper in landscape mode. + 2008-02-17 Douglas S. Blank * src/gen/lib/date.py (Date.__sub__): fixed some date math (#1649) * src/gen/lib/test/date_test.py: added some unit tests for date math diff --git a/src/plugins/StatisticsChart.py b/src/plugins/StatisticsChart.py index 55f3a1b94..11fa4f577 100644 --- a/src/plugins/StatisticsChart.py +++ b/src/plugins/StatisticsChart.py @@ -3,6 +3,7 @@ # # Copyright (C) 2003-2006 Donald N. Allingham # Copyright (C) 2007-2008 Brian G. Matherly +# Copyright (C) 2008 Peter Landgren # # 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 @@ -442,6 +443,10 @@ class Extract: if not no_years: # do not accept people who are not known to be in range continue + else: + continue + else: + continue self.get_person_data(person, data) return data @@ -566,10 +571,12 @@ class StatisticsChart(Report): def output_piechart(self, title, typename, data, lookup): # set layout variables - middle = self.doc.get_usable_width() / 2 + middle_w = self.doc.get_usable_width() / 2 + middle_h = self.doc.get_usable_height() / 2 + middle = min(middle_w,middle_h) # start output - self.doc.center_text('SC-title', title, middle, 0) + self.doc.center_text('SC-title', title, middle_w, 0) style_sheet = self.doc.get_style_sheet() pstyle = style_sheet.get_paragraph_style('SC-Title') yoffset = ReportUtils.pt2cm(pstyle.get_font().get_size()) @@ -584,14 +591,17 @@ class StatisticsChart(Report): chart_data.append((style, data[key], text)) color = (color+1) % 7 # There are only 7 color styles defined - margin = 1.0 - legendx = 2.0 + margin = 1.0 + legendx = 2.0 # output data... radius = middle - 2*margin yoffset = yoffset + margin + radius - ReportUtils.draw_pie_chart(self.doc, middle, yoffset, radius, chart_data, -90) - yoffset = yoffset + radius + margin + ReportUtils.draw_pie_chart(self.doc, middle_w, yoffset, radius, chart_data, -90) + yoffset = yoffset + radius + 2*margin + if middle == middle_h: # Landscape + legendx = 1.0 + yoffset = margin text = _("%s (persons):") % typename ReportUtils.draw_legend(self.doc, legendx, yoffset, chart_data, text,'SC-legend') @@ -696,12 +706,12 @@ class StatisticsChartOptions(MenuReportOptions): menu.add_option(category_name,"reverse", reverse) this_year = time.localtime()[0] - year_from = NumberOption(_("People Born Before"), + year_from = NumberOption(_("People Born After"), 1700, 1, this_year) year_from.set_help(_("Birth year from which to include people")) menu.add_option(category_name,"year_from", year_from) - year_to = NumberOption(_("People Born After"), + year_to = NumberOption(_("People Born Before"), this_year, 1, this_year) year_to.set_help(_("Birth year until which to include people")) menu.add_option(category_name,"year_to", year_to)