Beispiel #1
0
def home():
    employees = EmployeesModel.fetch_all_records()

    # calculate no of employees
    male = 0
    female = 0
    na = 0

    # using list comprehension and count method modify this for loop
    for emp in employees:
        if emp.gender == 'male':
            male += 1
        elif emp.gender == 'female':
            female += 1
        else:
            na += 1
    print(male)
    print(female)
    print(na)

    # create a pie chart
    pie_chart = pygal.Pie()
    pie_chart.title = 'Male vs Female Employees'
    pie_chart.add('Male Employees', male)
    pie_chart.add('Female Employees', female)
    pie_chart.add('Not Applicable', na)
    graph = pie_chart.render_data_uri()
    print(graph)
    return render_template('index.html', wafanyikazi=employees, graph=graph)
Beispiel #2
0
def home():
    employees = EmployeesModel.fetch_all_records()

    male = 0
    female = 0
    na = 0
    #use list comprehensions and count method to modify this for and if
    for emp in employees:
        if emp.gender == 'M':
            male += 1
        elif emp.gender == 'F':
            female += 1
        else:
            na += 1

    pie_chart = pygal.Pie()
    pie_chart.title = 'Male vs Female Employees'
    pie_chart.add('Male Employees ', male)
    pie_chart.add('Female Employees ', female)
    pie_chart.add('Not Applicable ', na)
    graph = pie_chart.render_data_uri()

    return render_template('index.html', wafanyikazi=employees, graph=graph)
Beispiel #3
0
def home():
    employees = EmployeesModel.fetch_all_records()
    return render_template('index.html',wafanyikazi = employees)