Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save davidcomfort/07b522b9cd0d7d1a706239e37a82922f to your computer and use it in GitHub Desktop.
Save davidcomfort/07b522b9cd0d7d1a706239e37a82922f to your computer and use it in GitHub Desktop.
html.Div([
dash_table.DataTable(
id='datatable-paid-search',
columns=[{"name": i, "id": i, 'deletable': True} for i in dt_columns]
+ [{"name": j, "id": j, 'hidden': 'True'} for j in conditional_columns],
editable=True,
n_fixed_columns=2,
style_table={'maxWidth': '1500px'},
row_selectable="multi",
selected_rows=[0],
style_cell = {"fontFamily": "Arial", "size": 10, 'textAlign': 'left'},
css=[{'selector': '.dash-cell div.dash-cell-value', 'rule': 'display: inline; white-space: inherit; overflow: inherit; text-overflow: inherit;'}],
style_cell_conditional=[{'if': {'row_index': 'odd'}, 'backgroundColor': '#D5DBDB'}]
+ [{'if': {'column_id': c}, 'backgroundColor': '#EAFAF1'} for c in ['Spend TY', 'Spend - LP', 'Spend PoP (Abs)', 'Spend PoP (%)', 'Spend LY', 'Spend YoY (%)',]]
+ [{'if': {'column_id': c, 'row_index': 'odd'}, 'backgroundColor': '#D5F5E3'} for c in ['Spend TY', 'Spend - LP', 'Spend PoP (Abs)', 'Spend PoP (%)', 'Spend LY', 'Spend YoY (%)',]]
+ [{'if': {'column_id': c}, 'backgroundColor': '#FEF9E7'} for c in ['Sessions - TY', 'Sessions - LP', 'Sessions - LY', 'Sessions PoP (%)', 'Sessions YoY (%)',]]
+ [{'if': {'column_id': c, 'row_index': 'odd'}, 'backgroundColor': '#FCF3CF'} for c in ['Sessions - TY', 'Sessions - LP', 'Sessions - LY', 'Sessions PoP (%)', 'Sessions YoY (%)',]]
+ [{'if': {'column_id': c}, 'backgroundColor': '#EBF5FB'} for c in ['Bookings - TY', 'Bookings - LP', 'Bookings PoP (%)', 'Bookings PoP (Abs)', 'Bookings - LY', 'Bookings YoY (%)', 'Bookings YoY (Abs)',]]
+ [{'if': {'column_id': c, 'row_index': 'odd'}, 'backgroundColor': '#D6EAF8'} for c in ['Bookings - TY', 'Bookings - LP', 'Bookings PoP (%)', 'Bookings PoP (Abs)', 'Bookings - LY', 'Bookings YoY (%)', 'Bookings YoY (Abs)',]]
+ [{'if': {'column_id': c},'backgroundColor': '#F4ECF7'} for c in ['CVR - TY', 'CVR - LP', 'CVR PoP (Abs)','CVR - LY', 'CVR YoY (Abs)', 'CVR PoP (%)', 'CVR YoY (%)']]
+ [{'if': {'column_id': c, 'row_index': 'odd'}, 'backgroundColor': '#E8DAEF' } for c in ['CVR - TY', 'CVR - LP', 'CVR PoP (Abs)','CVR - LY', 'CVR YoY (Abs)', 'CVR PoP (%)', 'CVR YoY (%)']]
+ [{'if': {'column_id': c}, 'backgroundColor': '#FDEDEC' } for c in ['CPA - TY', 'CPA - LP', 'CPA PoP (Abs)', 'CPA - LY', 'CPA YoY (Abs)','CPA PoP (%)', 'CPA YoY (%)' ]]
+ [{'if': {'column_id': c, 'row_index': 'odd'}, 'backgroundColor': '#FADBD8' } for c in ['CPA - TY', 'CPA - LP', 'CPA PoP (Abs)', 'CPA - LY', 'CPA YoY (Abs)', 'CPA PoP (%)', 'CPA YoY (%)']]
+ [{'if': {'column_id': c},'backgroundColor': '#F6DDCC'} for c in ['CPS - TY', 'CPS - LP', 'CPS PoP (Abs)', 'CPS - LY', 'CPS YoY (Abs)', 'CPS PoP (%)', 'CPA YoY (%)']]
+ [{'if': {'column_id': c, 'row_index': 'odd'}, 'backgroundColor': '#E59866' } for c in ['CPS - TY', 'CPS - LP', 'CPS PoP (Abs)', 'CPS - LY', 'CPS YoY (Abs)', 'CPS PoP (%)', 'CPA YoY (%)']]
+ [{'if': {'column_id': c}, 'minWidth': '0px', 'maxWidth': '80px', 'whiteSpace': 'normal'} for c in ['Spend TY', 'Spend - LP', 'Spend PoP (Abs)', 'Spend PoP (%)', 'Spend LY', 'Spend YoY (%)', 'Sessions - TY', 'Sessions - LP', 'Sessions - LY', 'Sessions PoP (%)',
'Sessions YoY (%)', 'Bookings - TY', 'Bookings - LP', 'Bookings PoP (%)', 'Bookings PoP (Abs)', 'Bookings - LY', 'Bookings YoY (%)', 'Bookings YoY (Abs)', 'Revenue - TY', 'Revenue - LP', 'Revenue PoP (Abs)', 'Revenue PoP (%)', 'Revenue - LY', 'Revenue YoY (%)', 'Revenue YoY (Abs)',]]
+ [{'if': {'column_id': 'Spend PoP (Abs)', 'filter': 'Spend_PoP_abs_conditional < num(0)'}, 'color': 'red'}]
+ [{'if': {'column_id': 'Spend PoP (%)', 'filter': 'Spend_PoP_percent_conditional < num(0)'}, 'color': 'red'}]
+ [{'if': {'column_id': 'Spend YoY (%)', 'filter': 'Spend_YoY_percent_conditional < num(0)'}, 'color': 'red'}]
+ [{'if': {'column_id': 'Sessions PoP (%)', 'filter': 'Sessions_PoP_percent_conditional < num(0)'}, 'color': 'red'}]
+ [{'if': {'column_id': 'Sessions YoY (%)', 'filter': 'Sessions_YoY_percent_conditional < num(0)'}, 'color': 'red'}]
+ [{'if': {'column_id': 'Bookings PoP (Abs)', 'filter': 'Bookings_PoP_abs_conditional < num(0)'}, 'color': 'red'}]
+ [{'if': {'column_id': 'Bookings YoY (Abs)', 'filter': 'Bookings_YoY_abs_conditional < num(0)'}, 'color': 'red'}]
+ [{'if': {'column_id': 'Bookings PoP (%)', 'filter': 'Bookings_PoP_percent_conditional < num(0)'}, 'color': 'red'}]
+ [{'if': {'column_id': 'Bookings YoY (%)', 'filter': 'Bookings_YoY_percent_conditional < num(0)'}, 'color': 'red'}]
+ [{'if': {'column_id': 'Revenue PoP (Abs)', 'filter': 'Revenue_PoP_abs_conditional < num(0)'}, 'color': 'red'}]
+ [{'if': {'column_id': 'Revenue YoY (Abs)', 'filter': 'Revenue_YoY_abs_conditional < num(0)'}, 'color': 'red'}]
+ [{'if': {'column_id': 'Revenue PoP (%)', 'filter': 'Revenue_PoP_percent_conditional < num(0)'}, 'color': 'red'}]
+ [{'if': {'column_id': 'Revenue YoY (%)', 'filter': 'Revenue_YoY_percent_conditional < num(0)'}, 'color': 'red'}],
style_header={'backgroundColor': 'black','color': 'white'},
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment