def make_bokeh_table(geosource, col_name: str = 'zip'): # Make a table of the numerical values that we can sort by dt_columns = [ TableColumn(field=col_name, title=col_name), TableColumn(field=col_name + '_percent', title='Percentage of users in ' + col_name), TableColumn(field=col_name + '_counts', title='Number of Users in ' + col_name) ] data_table = DataTable(source=geosource, columns=dt_columns) data_table.selectable = False data_table.editable = False data_table.scroll_to_selection = True data_table.reorderable = True data_table.sortable = True return data_table
def make_parameter_table(p_table, data, headers, table_width=None, table_height=None): if (data == None or headers == None): print('Making default data') data = dict( col1=[i for i in range(20)], col2=[i * i for i in range(20)], ) headers = dict(col1='Title 1', col2='Title 2') source = ColumnDataSource(data) columns = [] for key in data: if (key not in headers): raise ValueError(f'Header dictionary does not contain: {key}') columns = columns + [TableColumn(field=key, title=headers[key])] if (p_table == None): if (table_width == None or table_height == None): p_table = DataTable(source=source, columns=columns, editable=False, index_position=None) else: p_table = DataTable(source=source, columns=columns, width=table_width, height=table_height, editable=False, index_position=None) else: p_table.source = source p_table.columns = columns p_table.editable = False p_table.index_position = None if (table_width is not None): p_table.width = table_width if (table_height is not None): p_table.height = table_height return p_table