Add option to hide empty information on statistics chart

This commit is contained in:
Richard Clay 2018-11-14 16:07:21 +00:00 committed by Nick Hall
parent 06aa83e263
commit fb886c5954

View File

@ -769,6 +769,7 @@ class StatisticsChart(Report):
self.fil_name = "(%s)" % self.filter.get_name(self._locale) self.fil_name = "(%s)" % self.filter.get_name(self._locale)
self.bar_items = get_value('bar_items') self.bar_items = get_value('bar_items')
self.show_empty_information = get_value('show_empty_information')
year_from = get_value('year_from') year_from = get_value('year_from')
year_to = get_value('year_to') year_to = get_value('year_to')
gender = get_value('gender') gender = get_value('gender')
@ -918,6 +919,18 @@ class StatisticsChart(Report):
max_y = self.doc.get_usable_height() - row_h max_y = self.doc.get_usable_height() - row_h
pad = row_h * 0.5 pad = row_h * 0.5
# the list of keys that represent "missing" information
excluded_keys = [_T_("(Preferred) forename missing"),
_T_("Date(s) missing"),
_T_("Personal information missing"),
_T_("Birth missing"),
_T_("Children missing"),
]
# hide empty information
if not self.show_empty_information:
lookup = [k for k in lookup if k not in excluded_keys]
# check maximum value # check maximum value
max_value = max(data[k] for k in lookup) if lookup else 0 max_value = max(data[k] for k in lookup) if lookup else 0
# horizontal area for the gfx bars # horizontal area for the gfx bars
@ -1044,6 +1057,13 @@ class StatisticsChartOptions(MenuReportOptions):
"used instead of a bar chart.")) "used instead of a bar chart."))
add_option("bar_items", bar_items) add_option("bar_items", bar_items)
show_empty_information = BooleanOption(_("Include counts of missing information"),
False)
show_empty_information.set_help(_("Whether to include counts of the "
"number of people who lack the given "
"information."))
add_option("show_empty_information", show_empty_information)
################################ ################################
category_name = _("Report Options (2)") category_name = _("Report Options (2)")
add_option = partial(menu.add_option, category_name) add_option = partial(menu.add_option, category_name)