def number(decimals, sign=FormatTemplate.Sign.default, group=FormatTemplate.Group.yes): return FormatTemplate.Format(group=group, precision=decimals, scheme=FormatTemplate.Scheme.fixed, sign=sign, symbol=FormatTemplate.Symbol.no, group_delimiter='.', decimal_delimiter=',')
def md_contents_cb( view, state, cb_list, metric, def_top_fig, def_trend_fig, predict_btn_clcks, # clear_btn_clcks, modal_cls_btn_clcks, page_current, page_size, ): modal_style = {'display': 'none'} predict_btn_clcks, modal_cls_btn_clcks = 0, 0 changed_id = [p['prop_id'] for p in dash.callback_context.triggered][0] if ('predict_cntrl' in changed_id): predict_btn_clcks = 1 if ('modal_close_button' in changed_id): modal_cls_btn_clcks = 1 p_str = f""" get_tab_contents --------------- view = {view} state = {state} cb_list = {cb_list} metric = {metric} predict_btn_clcks = {predict_btn_clcks} modal_cls_btn_clcks = {modal_cls_btn_clcks} """ print(p_str) tab_data_df = df_rcnt[:100] md_txt, top_fig, \ trend_fig, tab_data_df, modal_txt = get_tab_contents( view, state, cb_list, metric, predict_btn_clcks, modal_cls_btn_clcks, ) if (top_fig == None): top_fig = def_top_fig if (trend_fig == None): trend_fig = def_trend_fig if (modal_txt != ""): modal_style = {'display': 'block'} col_fmt = dft.Format( nully='NA', precision=2, scheme=Scheme.fixed, ) cols = [{ 'name': i, "id": i, 'format': col_fmt } for i in (tab_data_df.columns)] data = tab_data_df.iloc[page_current * page_size:(page_current + 1) * page_size].to_dict('records') return ( md_txt, top_fig, trend_fig, cols, data, modal_style, modal_txt, )
from dash_table import FormatTemplate from dash_table.Format import Format, Group, Scheme, Symbol # dash_table columns format money = Format( scheme=Scheme.fixed, precision=2, group=Group.yes, groups=3, group_delimiter=".", decimal_delimiter=",", symbol=Symbol.yes, symbol_prefix="R$", ) percentage = FormatTemplate.Format( decimal_delimiter=",", precision=2, scheme=Scheme.fixed, symbol=Symbol.yes, symbol_suffix="%", ) # plotly graphs graph_money_prefix = "R$ " # Set locale. It is used to properly set number and currency. # Examples: # en_US.UTF-8 # pt_BR.utf8 my_locale = "pt_BR.utf8"