Skip to content

Commit

Permalink
better
Browse files Browse the repository at this point in the history
  • Loading branch information
quadrismegistus committed Feb 5, 2024
1 parent 6c4eb74 commit 102add9
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 16 deletions.
7 changes: 7 additions & 0 deletions geotaste/assets/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -584,4 +584,11 @@ button {
right:.75em;
padding:0;
margin:0;
}


.column-header-name {
font-size:.9em;
text-wrap:wrap;
font-weight:600;
}
23 changes: 16 additions & 7 deletions geotaste/figs.py
Original file line number Diff line number Diff line change
Expand Up @@ -844,13 +844,15 @@ def book_filters_exist(self):
for fn in self.filter_data)

def table_arrond(self):
return generate_table(self. data, 'arrond_id', 'arrond')
return generate_table(self. data, 'arrond_id', 'arrond',sort_by='arrond_num_members')
def table_members(self):
return generate_table(self.data, 'member')
df=self.data.sample(frac=1)
df['member_num_years_of_membership'] = df['member_membership'].apply(len)
return generate_table(df, 'member',sort_by='member_num_years_of_membership')
def table_books(self):
return generate_table(self.data, 'book', also_cols={'author_name'})
return generate_table(self.data.drop(['book_numborrow','book_circulated'],axis=1), 'book', also_cols={'author_name'},sort_by='book_num_members')
def table_authors(self):
return generate_table(self.data, 'author')
return generate_table(self.data, 'author',sort_by='author_num_members')


def table(self, tab=None, **kwargs):
Expand Down Expand Up @@ -1588,7 +1590,7 @@ def store_all_markers_in_assets_folder(ofn=None):
def preprocess_df(data):
return delist_df(data).fillna('').applymap(ensure_int)

def generate_table(data, group_by_field, entity_prefix=None, sort_by=None, also_cols=None):
def generate_table(data, group_by_field, entity_prefix=None, sort_by=None, sort_by_asc=False,also_cols=None):
if not entity_prefix: entity_prefix=group_by_field
df = preprocess_df(data)
df = df[df[group_by_field] != ""]
Expand Down Expand Up @@ -1616,9 +1618,16 @@ def generate_table(data, group_by_field, entity_prefix=None, sort_by=None, also_
]
rename = {c: c.split(f"{entity_prefix}_", 1)[-1].replace('_',' ').title() for c in cols}
rename[group_by_field] = entity_prefix.title()
if not sort_by: sort_by=cols[-1]
return get_dash_table(
df.sort_values(df.columns[-1] if not sort_by else sort_by),
df.sort_values(sort_by, ascending=sort_by_asc),
cols=cols,
rename=rename,
sort_by=[{'id': '0', 'direction': 'asc'}] if not sort_by else None,
# sort_by=[{'id': '0', 'direction': 'asc'}] if not sort_by else None,
sort_by=[
{
'id': cols.index(sort_by),
'direction': 'asc' if sort_by_asc else 'desc'
}
]
)
15 changes: 6 additions & 9 deletions geotaste/layouts.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,22 +92,19 @@ def component_callbacks(self, app):
Output(card.store, 'data', allow_duplicate=True)
for panel in [self.comparison_panel.L, self.comparison_panel.R]
for card in panel.store_subcomponents
]
] + [Output(self.comparison_panel.mainview_tabs, 'active_tab',allow_duplicate=True)]
num_outputs=len(outputs)

app.clientside_callback(
"""
function toggle(clk1){ return new Array("""+str(num_outputs)+""").fill({}); }
function toggle(clk1){
var arr = new Array("""+str(num_outputs)+""").fill({});
arr.push("map");
return arr;
}
""",
outputs,
# Output('welcome-modal','is_open',allow_duplicate=True),

# [
# Output(self.comparison_panel.L.store_incoming, 'data', allow_duplicate=True),
# Output(self.comparison_panel.R.store_incoming, 'data', allow_duplicate=True),
# ],
Input('logo_popup', 'n_clicks'),
# State('welcome-modal', 'is_open'),
prevent_initial_call=True
)

0 comments on commit 102add9

Please sign in to comment.