Hi back here with another problem, I’m creating a big dashboard which reads from an sql server a csv file and has different outputs. I create a dash datable that’s filtered by some values which gets created correctly, now I’m trying to style it. I was able to add some color on the cells but now I’m stuck trying to change a value to money. Simply what I need is to change normal values like 100, 240 to 100$ 240$ on my output.
Here’s a litlle version of my code omitting the parts like loading data and others:
‘’’
html.Div([
dash_table.DataTable(
id='Worst_stations_table',
style_cell={'textAlign': 'left'},
style_data_conditional=[{'if': {'column_id': 'Cost Benefit ',
'filter_query': '{Cost Benefit } > 0', },
'backgroundColor': '#3D9970',
'color': 'white'}, ],
)
], className='three columns'),
])
@app.callback(
[Output(‘Worst_stations_table’,‘data’),Output(‘Worst_stations_table’, ‘columns’)],
[Input(‘Week-choose’,‘value’)]
)
def update_value(Weeekee):
Worst_stations_table = Hyper_filtered[(Hyper_filtered[‘Cost Benefit’] < 200)]
Columns_worst_stations = [‘Station’, ‘Cost Benefit’, ‘Week’]
Worst_stations_table = Worst_stations_table[Columns_worst_stations]
Worst_station_filtered_week= Worst_stations_table[Worst_stations_table['Week']== Weeekee]
Worst_station_filtered_week_columns = ['Station', 'Cost Benefit']
Worst_station_filtered_week_columns=Worst_station_filtered_week[Worst_station_filtered_week_columns]
Worst_station_filtered_week_columns= Worst_station_filtered_week_columns.sort_values(by='Cost Benefit')
columns= [{'name': i, 'id': i} for i in Worst_station_filtered_week_columns.columns]
data= Worst_station_filtered_week_columns.to_dict('rows')
return data, columns
‘’’
with this part I’m able to highlight the values I want now I just need to style them. I know that the callback is as messy as it gets but is working correctly and I’m gonna perfect it later.
Thanks