Exemple #1
0
    def charts(self):
        data = self.rows
        chart_data = []
        if data:
            reported_percent = round((data['reported']) * 100 / float(data['total'] or 1))
            non_reported_percent = round((data['non_reported']) * 100 / float(data['total'] or 1))
            reported_formatted = ("%d" if reported_percent.is_integer() else "%.1f") % reported_percent
            non_reported_formatted = ("%d" if non_reported_percent.is_integer() else "%.1f") % non_reported_percent

            chart_data = sorted([
                dict(value=non_reported_percent,
                     label=_('Non-Reporting %s%%') % non_reported_formatted,
                     description=_(
                         "%(formatted_percent)s%% (%(raw_number)d) Non-Reported (%(date_range)s)"
                     ) % {
                         'formatted_percent': non_reported_formatted,
                         'raw_number': data['non_reported'],
                         'date_range': self.datetext(),
                     },
                     color='red'),
                dict(value=reported_percent,
                     label=_('Reporting %s%%') % reported_formatted,
                     description=_(
                         "%(formatted_percent)s%% (%(raw_number)d) Reported (%(date_range)s)"
                     ) % {
                         'formatted_percent': reported_formatted,
                         'raw_number': data['reported'],
                         'date_range': self.datetext(),
                     },
                     color='green'),
            ], key=lambda x: x['value'], reverse=True)
        pie_chart = EWSPieChart('', '', chart_data, [chart_data[0]['color'], chart_data[1]['color']])
        pie_chart.tooltips = False
        return [pie_chart]
Exemple #2
0
 def charts(self):
     data = self.rows
     chart_data = []
     if data:
         complete_percent = round((data['complete']) * 100 / float(data['total'] or 1))
         incomplete_percent = round((data['incomplete']) * 100 / float(data['total'] or 1))
         complete_formatted = ("%d" if complete_percent.is_integer() else "%.1f") % complete_percent
         incomplete_formatted = ("%d" if incomplete_percent.is_integer() else "%.1f") % incomplete_percent
         chart_data = [
             dict(value=complete_formatted,
                  label=_('Complete %s%%') % complete_formatted,
                  description=_(
                      "%(formatted_percent)s%% (%(raw_number)d) Complete Reports in %(date_range)s"
                  ) % {
                      'formatted_percent': complete_formatted,
                      'raw_number': data['complete'],
                      'date_range': self.datetext()
                  },
                  color='green'),
             dict(value=incomplete_formatted,
                  label=_('Incomplete %s%%') % incomplete_formatted,
                  description=_(
                      "%(formatted_percent)s%% (%(raw_number)d) Incomplete Reports in %(date_range)s"
                  ) % {
                      'formatted_percent': incomplete_formatted,
                      'raw_number': data['incomplete'],
                      'date_range': self.datetext(),
                  },
                  color='purple'),
         ]
     pie_chart = EWSPieChart('', '', chart_data, ['green', 'purple'])
     pie_chart.tooltips = False
     return [pie_chart]
    def charts(self):
        data = self.rows
        chart_data = []
        if data:
            reported_percent = round((data["reported"]) * 100 / float(data["total"] or 1))
            non_reported_percent = round((data["non_reported"]) * 100 / float(data["total"] or 1))
            reported_formatted = ("%d" if reported_percent.is_integer() else "%.1f") % reported_percent
            non_reported_formatted = ("%d" if non_reported_percent.is_integer() else "%.1f") % non_reported_percent

            chart_data = sorted(
                [
                    dict(
                        value=non_reported_percent,
                        label=_("Non-Reporting %s%%" % non_reported_formatted),
                        description=_(
                            "%s%% (%d) Non-Reported (%s)"
                            % (non_reported_formatted, data["non_reported"], self.datetext())
                        ),
                        color="red",
                    ),
                    dict(
                        value=reported_percent,
                        label=_("Reporting %s%%" % reported_formatted),
                        description=_(
                            "%s%% (%d) Reported (%s)" % (reported_formatted, data["reported"], self.datetext())
                        ),
                        color="green",
                    ),
                ],
                key=lambda x: x["value"],
                reverse=True,
            )
        pie_chart = EWSPieChart("", "", chart_data, [chart_data[0]["color"], chart_data[1]["color"]])
        pie_chart.tooltips = False
        return [pie_chart]
 def charts(self):
     data = self.rows
     chart_data = []
     if data:
         complete_percent = round((data["complete"]) * 100 / float(data["total"] or 1))
         incomplete_percent = round((data["incomplete"]) * 100 / float(data["total"] or 1))
         complete_formatted = ("%d" if complete_percent.is_integer() else "%.1f") % complete_percent
         incomplete_formatted = ("%d" if incomplete_percent.is_integer() else "%.1f") % incomplete_percent
         chart_data = [
             dict(
                 value=complete_formatted,
                 label=_("Complete %s%%") % complete_formatted,
                 description=_("%s%% (%d) Complete Reports in %s")
                 % (complete_formatted, data["complete"], self.datetext()),
                 color="green",
             ),
             dict(
                 value=incomplete_formatted,
                 label=_("Incomplete %s%%") % incomplete_formatted,
                 description=_("%s%% (%d) Incomplete Reports in %s")
                 % (incomplete_formatted, data["incomplete"], self.datetext()),
                 color="purple",
             ),
         ]
     pie_chart = EWSPieChart("", "", chart_data, ["green", "purple"])
     pie_chart.tooltips = False
     return [pie_chart]
 def charts(self):
     data = self.rows
     chart_data = []
     if data:
         complete_percent = round((data['complete']) * 100 / (data['total'] or 1))
         incomplete_percent = round((data['incomplete']) * 100 / (data['total'] or 1))
         complete_formatted = ("%d" if complete_percent.is_integer() else "%.1f") % complete_percent
         incomplete_formatted = ("%d" if incomplete_percent.is_integer() else "%.1f") % incomplete_percent
         chart_data = [
             dict(value=complete_formatted,
                  label=_('Complete'),
                  description=_("%s%% (%d) Complete Reports in %s" %
                                (complete_formatted, data['complete'], self.datetext())),
                  color='green'),
             dict(value=incomplete_formatted,
                  label=_('Incomplete'),
                  description=_("%s%% (%d) Incomplete Reports in %s" %
                                (incomplete_formatted, data['incomplete'], self.datetext())),
                  color='purple'),
         ]
     pie_chart = EWSPieChart('', '', chart_data, ['green', 'purple'])
     pie_chart.tooltips = False
     return [pie_chart]
    def charts(self):
        data = self.rows
        chart_data = []
        if data:
            reported_percent = float(data['reported']) * 100 / (data['total'] or 1)
            non_reported_percent = float(data['non_reported']) * 100 / (data['total'] or 1)
            reported_formatted = ("%d" if reported_percent.is_integer() else "%.1f") % reported_percent
            non_reported_formatted = ("%d" if non_reported_percent.is_integer() else "%.1f") % non_reported_percent

            chart_data = [
                dict(value=reported_percent,
                     label=_('Reporting'),
                     description=_("%s%% (%d) Reported (%s)" % (reported_formatted, data['reported'],
                                                                self.datetext())),
                     color='green'),
                dict(value=non_reported_percent,
                     label=_('Non-Reporting'),
                     description=_("%s%% (%d) Non-Reported (%s)" %
                                   (non_reported_formatted, data['non_reported'], self.datetext())),
                     color='red'),
            ]
        pie_chart = EWSPieChart('', '', chart_data, ['green', 'red'])
        pie_chart.tooltips = False
        return [pie_chart]