Esempio n. 1
0
def genfoodchart(start, end):
    '''Generate food chart with Pygal'''
    now = datetime.datetime.now().strftime("%Y-%m-%d")
    goodcount = session.query(Food) \
        .filter_by(user_id=current_user.id) \
        .filter(Food.food_date.between(start, end)).join(Ranks) \
        .filter_by(rank=1).add_columns(Ranks.rank).count()
    okaycount = session.query(Food) \
        .filter_by(user_id=current_user.id) \
        .filter(Food.food_date.between(start, end)).join(Ranks) \
        .filter_by(rank=2).add_columns(Ranks.rank).count()
    badcount = session.query(Food) \
        .filter_by(user_id=current_user.id) \
        .filter(Food.food_date.between(start, end)).join(Ranks) \
        .filter_by(rank=3).add_columns(Ranks.rank).count()

    custom_style = Style(
                    background='transparent',
                    value_font_size=24,
                    title_font_size=36,
                    margin=1,
                    plot_background='transparent',
                    foreground='#53E89B',
                    foreground_strong='#53A0E8',
                    foreground_subtle='#630C0D',
                    opacity='.6',
                    opacity_hover='.9',
                    transition='400ms ease-in',
                    colors=('#5cb85c', '#f0ad4e', '#d9534f'))

    config = Config()
    config.show_legend = True
    config.legend_at_bottom=True
    config.legend_at_bottom_columns=1
    config.legend_box_size=10
    config.human_readable = True
    config.fill = True
    config.style=custom_style
    config.print_labels=True
    config.print_values=True
    config.no_data_text='Need to add some food!'

    pie_chart = pygal.Pie(config)
    pie_chart.title = "Current Food Stats"
    pie_chart.add('Good', goodcount)
    pie_chart.add('Okay', okaycount)
    pie_chart.add('Bad', badcount)
    chart = pie_chart.render(is_unicode=True)
    return chart
Esempio n. 2
0
def genfoodchart(start, end):
    '''Generate food chart with Pygal'''
    now = datetime.datetime.now().strftime("%Y-%m-%d")
    goodcount = session.query(Food) \
        .filter_by(user_id=current_user.id) \
        .filter(Food.food_date.between(start, end)).join(Ranks) \
        .filter_by(rank=1).add_columns(Ranks.rank).count()
    okaycount = session.query(Food) \
        .filter_by(user_id=current_user.id) \
        .filter(Food.food_date.between(start, end)).join(Ranks) \
        .filter_by(rank=2).add_columns(Ranks.rank).count()
    badcount = session.query(Food) \
        .filter_by(user_id=current_user.id) \
        .filter(Food.food_date.between(start, end)).join(Ranks) \
        .filter_by(rank=3).add_columns(Ranks.rank).count()

    custom_style = Style(
                    background='transparent',
                    value_font_size=24,
                    title_font_size=36,
                    margin=1,
                    plot_background='transparent',
                    foreground='#53E89B',
                    foreground_strong='#53A0E8',
                    foreground_subtle='#630C0D',
                    opacity='.6',
                    opacity_hover='.9',
                    transition='400ms ease-in',
                    colors=('#5cb85c', '#f0ad4e', '#d9534f'))

    config = Config()
    config.show_legend = True
    config.legend_at_bottom=True
    config.legend_at_bottom_columns=1
    config.legend_box_size=10
    config.human_readable = True
    config.fill = True
    config.style=custom_style
    config.print_labels=True
    config.print_values=True
    config.no_data_text='Need to add some food!'

    pie_chart = pygal.Pie(config)
    pie_chart.title = "Current Food Stats"
    pie_chart.add('Good', goodcount)
    pie_chart.add('Okay', okaycount)
    pie_chart.add('Bad', badcount)
    chart = pie_chart.render(is_unicode=True)
    return chart
Esempio n. 3
0
def PygalConfigFile():
    config = Config()
    config.human_readable = True
    config.height = 250
    config.width = 700
    config.style = NeonStyle
    config.show_minor_y_labels = True
    config.x_label_rotation = 25
    config.value_font_size = 8
    config.title_font_size = 8
    config.legend_font_size = 8
    config.legend_box_size = 12
    config.label_font_size = 6

    return (config)
Esempio n. 4
0
def PygalConfigFileBlue():
    configB = Config()
    configB.human_readable = True
    configB.height = 250
    configB.width = 700
    configB.style = NeonStyle
    configB.show_minor_y_labels = True
    configB.x_label_rotation = 25
    configB.value_font_size = 8
    configB.title_font_size = 8
    configB.legend_font_size = 8
    configB.legend_box_size = 12
    configB.label_font_size = 6
    configB.colors = ['#000099', '#009999']

    return (configB)
  foreground_subtle='#0B6121',
  legend_font_size=15,
  title_font_size=20,
  legend_box_size=20,
  colors=('#04B404', 'green', 'green', 'green'))
  
#Style für die Top20 Weltkarten
world_style2 = Style(
  background='transparent',
  plot_background='#f0efff',
  title_font_size=17,)

#Diagramm-Einstellungen
config = Config()
config.rounded_bars=5
config.legend_box_size=20
config.x_label_rotation=90
config.fill=True

#Horizontales Histogramm mit Vergleich zwischen Installationszahlen 2015 und 2016
chart = pygal.HorizontalBar(style=chart_style1,legend_box_size=20)
chart.title = 'Installationen 2015 und 2016'
chart.add('2015', summe_installs_2015, rounded_bars=5)
chart.add('2016', summe_installs_2016, rounded_bars=5)
chart.render_to_file('charts/installs_compared_2015_2016.svg')

#Kreisdiagramm mit Deinstallations- und "Behalten"-Quote von 2015
pie_chart = pygal.Pie(style=chart_style1,legend_box_size=20)
pie_chart.title = 'Deinstallationsquote 2015'
pie_chart.add('Deinstalliert in %', round(deinstallationsquote_2015,1))
pie_chart.add('Behalten in %', round(behalten_quote_2015,1))
Esempio n. 6
0
global loadAvg5Min
global loadAvg1Min
global MemUsage
global diskUsage

global sender
global receivers

sender = 'Monito admin <*****@*****.**>'
receivers = ['*****@*****.**']

config = Config()
config.range=(.0001, 5)
config.legend_font_size=30
config.tooltip_font_size=30
config.legend_box_size=18
config.title_font_size=30
config.label_font_size=20
config.legend_at_bottom=True
config.major_label_font_size=20
config.no_data_text='Fetching data..'

config1 = Config()
config1.fill=True
config1.spacing=50
config1.range=(1, 100)
config1.legend_font_size=30
config1.tooltip_font_size=30
config1.legend_box_size=18
config1.title_font_size=30
config1.label_font_size=20