Пример #1
0
def set_table_columns(columns):
    if columns is None:
        raise PreventUpdate
    return [{
        'id': c,
        'name': c.replace('_', ' ').title(),
        'type': 'numeric' if 'ount' in c else 'text',
        'format': Format(group=',') if 'ount' in c else None
    } for c in columns]
Пример #2
0
def populate_table_data(serp_results):
    if serp_results is None:
        raise PreventUpdate
    df = pd.DataFrame(serp_results, columns=serp_results[0].keys())
    del df['pagemap']
    columns = [{'name': re.sub('[A-Z]', r' \g<0>', x).title(), 'id': x,
                'format': Format(group=',') if 'esults' in x else None}
               for x in df.columns]
    last_col = df.columns.tolist().index('totalResults') + 1
    return df.iloc[:, :last_col].to_dict('rows'), columns[:last_col]
Пример #3
0
     dcc.Loading([
         DataTable(
             id='table',
             style_cell={
                 'font-family': 'Source Sans Pro',
                 'minWidth': 100
             },
             columns=[{
                 'name':
                 i,
                 'id':
                 i,
                 'type':
                 'numeric' if i == 'Tweet Volume' else None,
                 'format':
                 Format(group=',') if i == 'Tweet Volume' else None
             } for i in TABLE_COLS],
             sort_action='native',
             fixed_rows={
                 'headers': True,
                 'data': 0
             },
             data=pd.DataFrame(
                 {k: ['' for i in range(10)]
                  for k in TABLE_COLS}).to_dict('rows'),
         ),
     ]),
 ],
 style={
     'width': '95%',
     'margin-left': '2.5%',
Пример #4
0
     'textAlign': 'right'
 }, {
     'if': {
         'column_id': 'Topic'
     },
     'textAlign': 'center'
 }],
 columns=[{
     'name':
     i,
     'id':
     i,
     'type':
     'numeric' if i == 'Tweet Volume' else None,
     'format':
     Format(group=',')
     if i == 'Tweet Volume' else None
 } for i in TABLE_COLS],
 sort_action='native',
 export_headers='names',
 export_format='csv',
 page_action='none',
 style_table={'overflowX': 'scroll'},
 fixed_rows={
     'headers': True,
     'data': 0
 },
 data=pd.DataFrame({
     k: ['' for i in range(10)]
     for k in TABLE_COLS
 }).to_dict('rows'))
Пример #5
0
                                         style_header={'textAlign': 'center'},
                                         style_cell={'font-family': 'Source Sans Pro',
                                                     'minWidth': 100,
                                                     'textAlign': 'left'
                                                     },
                                         style_cell_conditional=[
                                             {'if': {'column_id': 'Tweet Volume'},
                                              'textAlign': 'right'},
                                             {'if': {'column_id': 'Local Rank'},
                                              'textAlign': 'right'},
                                             {'if': {'column_id': 'Topic'},
                                              'textAlign': 'center'}
                                         ],
                                         columns=[{'name': i, 'id': i,
                                                   'type': 'numeric' if i == 'Tweet Volume' else None,
                                                   'format': Format(group=',')
                                                   if i == 'Tweet Volume' else None}
                                                  for i in TABLE_COLS],
                                         sort_action='native',
                                         export_headers='names',
                                         export_format='csv',
                                         page_action='none',
                                         style_table={'overflowX': 'scroll'},
                                         fixed_rows={'headers': True, 'data': 0},
                                         data=pd.DataFrame({
                                             k: ['' for i in range(10)] for k in TABLE_COLS
                                         }).to_dict('rows'))
                           ], lg=10),
                       ], style={'font-family': 'Source Sans Pro','width':'122%','margin-left':'-165px'}),
    ] ,style={'backgroundColor': "#000000", 'margin-top':'-30px', 'height':'2000px'},
)