Py.Cafe

maartenbreddels/

ipyaggrid-olympic-data

Interactive Olympic Winners Dashboard with Ag-Grid

DocsPricing
  • app.py
  • requirements.txt
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import ipyaggrid
import json
import pandas as pd

dfm = pd.read_json("OlympicWinners.json")

column_defs = [{'field': c} for c in dfm.columns[:]]

grid_options = {
    'columnDefs' : column_defs,
}

buttons = [
    {'name':'Expand All', 'action':'''gridOptions.api.expandAll();'''},
    {'name':'Collapse All', 'action':'''gridOptions.api.collapseAll();'''},
]


grid_options = {
    'columnDefs' : column_defs,
    # 'enableSorting': True,
    # 'enableFilter': True,
    # 'enableColResize': True,
    # 'enableRangeSelection': True,
    # 'groupDefaultExpanded':1,
    # 'groupDisplayType':'multipleColumns',
    # 'suppressAggFuncInHeader':True,
    # 'groupRemoveLowestSingleChildren': False
}


 

# default_col_defs = {
#     'flex':1,
#     'resizable': True,
#     'wrapText': True,
#     'wrapHeaderText':True,
#     'autoHeight': True,
#     'autoHeaderHeight': True,
#     "cellStyle": {"wordBreak": "normal"}
# }

# auto_group_column_def = {
#     'cellRendererParams' : {
#         'suppressCount': True,
#     },
# }

agGridLicenseKey = "community"

page = ipyaggrid.Grid(
    grid_data=dfm,
    height=800,
    theme='ag-theme-balham',
    grid_options=grid_options,
    quick_filter=True,
    columns_fit='size_to_fit',
    compress_data=True,
    menu={'buttons':buttons},
    license=agGridLicenseKey
)