Exemplo n.º 1
0
    def get_chart(self, records, garden):
        df = pd.DataFrame.from_records(records.values('total_tags', 'recorded'),
                                       coerce_float=True)

        qdf = df.groupby('recorded').sum()['total_tags']
        return vertical_bar(qdf, make_chart_name('lookinggood', garden),
                            shape='short', ylabel='TAGS')
Exemplo n.º 2
0
    def get_chart(self, records, garden):
        df = pd.DataFrame.from_records(records.values('crop__name', 'yum_after'),
                                       coerce_float=True)

        qdf = df.groupby('crop__name').sum()['yum_after']
        return vertical_bar(qdf, make_chart_name('yumyuck', garden),
                            ylabel='YUMS AFTER TASTING')
Exemplo n.º 3
0
 def get_chart(self, records, garden):
     df = pd.DataFrame.from_records(records.values(*age_fields), coerce_float=True)
     columns = dict([(a, a.replace('age_', '').replace('_', '-')) for a in age_fields])
     columns['age_10'] = 'under 10'
     columns['age_65'] = '65+'
     df = df.rename(columns=columns).sum().transpose()
     return vertical_bar(df, make_chart_name('reach_age', garden),
                         ylabel='PARTICIPANTS')
    def get_chart(self, records, garden):
        df = pd.DataFrame.from_records(records.values('out_half', 'out_whole', 'recorded'),
                                       coerce_float=True)

        df['out_total'] = (df.out_half / 2.0) + df.out_whole
        qdf = df.groupby('recorded').sum()['out_total']
        return vertical_bar(qdf, make_chart_name('participation_geography_out', garden),
                            color='#F63C04', ylabel='HOURS', shape='short')
 def get_chart(self, records, garden):
     df = pd.DataFrame.from_records(records.values('weight', 'recorded'),
                                    coerce_float=True)
     qdf = df.groupby('recorded').sum()['weight']
     qdf = qdf.apply(lambda x: to_preferred_weight_units(x, garden, force_large_units=True).magnitude)
     units = preferred_weight_units(garden, large=True)
     return vertical_bar(qdf, make_chart_name('landfilldiversion_weight', garden),
                         ylabel=units.upper(), shape='short')
Exemplo n.º 6
0
    def get_chart(self, records, garden, shared):
        df = pd.DataFrame.from_records(records.values(shared, 'recorded'),
                                       coerce_float=True)

        qdf = df.groupby('recorded').sum()[shared]
        return vertical_bar(qdf, make_chart_name('skills_%s' % shared, garden),
                            shape='short',
                            ylabel='NUMBER OF %s' % shared.upper().replace('_', ' '))
Exemplo n.º 7
0
    def get_chart(self, records, garden):
        records = records.filter(volume__isnull=False)
        df = pd.DataFrame.from_records(records.values('volume', 'recorded'),
                                       coerce_float=True)

        qdf = df.groupby('recorded').sum()['volume']
        return vertical_bar(qdf, make_chart_name('rainwater', garden),
                            ylabel='GALLONS', shape='short')
Exemplo n.º 8
0
    def get_chart(self, records, garden):
        df = pd.DataFrame.from_records(records.values('crop__name',
                                                      'yum_after'),
                                       coerce_float=True)

        qdf = df.groupby('crop__name').sum()['yum_after']
        return vertical_bar(qdf,
                            make_chart_name('yumyuck', garden),
                            ylabel='YUMS AFTER TASTING')
Exemplo n.º 9
0
    def get_chart(self, records, garden, shared):
        df = pd.DataFrame.from_records(records.values(shared, 'recorded'),
                                       coerce_float=True)

        qdf = df.groupby('recorded').sum()[shared]
        return vertical_bar(qdf,
                            make_chart_name('skills_%s' % shared, garden),
                            shape='short',
                            ylabel='NUMBER OF %s' %
                            shared.upper().replace('_', ' '))
Exemplo n.º 10
0
 def get_chart(self, records, garden):
     df = pd.DataFrame.from_records(records.values(*age_fields),
                                    coerce_float=True)
     columns = dict([(a, a.replace('age_', '').replace('_', '-'))
                     for a in age_fields])
     columns['age_10'] = 'under 10'
     columns['age_65'] = '65+'
     df = df.rename(columns=columns).sum().transpose()
     return vertical_bar(df,
                         make_chart_name('reach_age', garden),
                         ylabel='PARTICIPANTS')
Exemplo n.º 11
0
    def get_chart(self, records, garden):
        df = pd.DataFrame.from_records(records.values('weight', 'recorded'),
                                       coerce_float=True)

        qdf = df.groupby('recorded').sum()['weight']
        qdf = qdf.apply(lambda x: to_preferred_weight_units(x, garden,
                                                            force_large_units=True).magnitude)
        units = preferred_weight_units(garden, large=True)
        return vertical_bar(qdf, make_chart_name('donations', garden),
                            xlabel=('%s donated by period' % units).upper(),
                            ylabel=units.upper())
Exemplo n.º 12
0
    def get_chart(self, records, garden):
        df = pd.DataFrame.from_records(records.values('volume', 'recorded'),
                                       coerce_float=True)

        qdf = df.groupby('recorded').sum()['volume']
        qdf = qdf.apply(lambda x: to_preferred_volume_units(garden,
                                                            cubic_meters=x,
                                                            force_large_units=True).magnitude)
        units = preferred_volume_units(garden, large=True)
        return vertical_bar(qdf, make_chart_name('compost_volume', garden),
                            ylabel=units.upper(), shape='short')
Exemplo n.º 13
0
    def get_chart(self, records, garden):
        df = pd.DataFrame.from_records(records.values('weight', 'recorded'),
                                       coerce_float=True)
        qdf = df.groupby('recorded').sum()['weight']
        qdf = qdf.apply(lambda x: to_preferred_weight_units(
            x, garden, force_large_units=True).magnitude)

        units = preferred_weight_units(garden, large=True)
        return vertical_bar(qdf,
                            make_chart_name('compost_weight', garden),
                            ylabel=units.upper(),
                            shape='short')
Exemplo n.º 14
0
    def get_chart(self, records, garden):
        df = pd.DataFrame.from_records(records.values('in_half', 'in_whole',
                                                      'recorded'),
                                       coerce_float=True)

        df['in_total'] = (df.in_half / 2.0) + df.in_whole
        qdf = df.groupby('recorded').sum()['in_total']
        return vertical_bar(qdf,
                            make_chart_name('participation_geography_in',
                                            garden),
                            ylabel='HOURS',
                            shape='short')
    def get_chart(self, records, garden):
        df = pd.DataFrame.from_records(records.values('volume', 'recorded'),
                                       coerce_float=True)

        qdf = df.groupby('recorded').sum()['volume']
        qdf = qdf.apply(lambda x: to_preferred_volume_units(
            garden, cubic_meters=x, force_large_units=True).magnitude)
        units = preferred_volume_units(garden, large=True)
        return vertical_bar(qdf,
                            make_chart_name('landfilldiversion_volume',
                                            garden),
                            ylabel=units.upper(),
                            shape='short')
 def get_chart(self, records, garden):
     project_records = []
     for r in records:
         project_records.append({
             'hours': r.projecthours_set.all().aggregate(h=Sum('hours'))['h'],
             'project': r.project,
         })
     df = pd.DataFrame.from_records(project_records, coerce_float=True) \
         .sort(columns='project') \
         .groupby('project') \
         .sum()['hours']
     return vertical_bar(df, make_chart_name('participation_project', garden),
                         ylabel='HOURS')
 def get_chart(self, records, garden, task):
     task_records = []
     for r in records:
         task_records.append({
             'hours': r[str(task)].hours,
             'recorded': r.recorded,
         })
     df = pd.DataFrame.from_records(task_records)
     qdf = df.groupby('recorded').sum()['hours']
     return vertical_bar(
         qdf,
         make_chart_name('participation_task_%s' % task.replace('/', '_'), garden),
         ylabel='HOURS', shape='short'
     )
Exemplo n.º 18
0
 def get_chart(self, records, garden, task):
     task_records = []
     for r in records:
         task_records.append({
             'hours': r[str(task)].hours,
             'recorded': r.recorded,
         })
     df = pd.DataFrame.from_records(task_records)
     qdf = df.groupby('recorded').sum()['hours']
     return vertical_bar(
         qdf,
         make_chart_name('participation_task_%s' % task.replace('/', '_'),
                         garden),
         ylabel='HOURS',
         shape='short')
Exemplo n.º 19
0
 def get_chart(self, records, garden):
     project_records = []
     for r in records:
         project_records.append({
             'hours':
             r.projecthours_set.all().aggregate(h=Sum('hours'))['h'],
             'project':
             r.project,
         })
     df = pd.DataFrame.from_records(project_records, coerce_float=True) \
         .sort(columns='project') \
         .groupby('project') \
         .sum()['hours']
     return vertical_bar(df,
                         make_chart_name('participation_project', garden),
                         ylabel='HOURS')
Exemplo n.º 20
0
 def get_chart(self, records, garden):
     chart_counts = self.find_moods_difference(records, 'negative')
     df = pd.DataFrame.from_records(chart_counts, coerce_float=True)
     return vertical_bar(df.groupby('mood').sum()['change'],
                         make_chart_name('moods_negative', garden),
                         ylabel='CHANGE IN NEGATIVE MOODS', shape='short')