@plotlynewbie wrote:
Hi there,
I want to render a dash table that updates itself each second which perfectly works.
Besides that, I have found this amazing feature to highlight certain values (please refer to: https://dash.plot.ly/datatable/style - Conditional formatting - highlighting cells).Is there someone who could help me to apply it on my use case:
This is my test data set (json format):
[
{
“A”: “angry”,
“Percentage”: 120
},
{
“A”: “sad”,
“Percentage”: 12.4
},
{
“A”: “happy”,
“Percentage”: 1.5
},
{
“A”: “bored”,
“Percentage”: 99
}
]and my function looks like:
@app.callback(Output(‘resulttable2’,‘children’),
[Input(‘interval-component’,‘n_intervals’)])
def generate_table2(max_rows=10):
df = pd.read_json(‘test.json’)
arr=np.array(df[“Percentage”], dtype=float)
arr2 = np.int64(arr)
maxvalue = max(arr2)
return dash_table.DataTable(
id=‘table’,
columns=[{“name”: i, “id”: i} for i in df.columns],
data=df.to_dict(‘records’),
style_data_conditional=[
{
‘if’: {
‘column_id’: ‘Percentage’,
‘filter_query’: ‘{Percentage} > maxvalue’
},
‘backgroundColor’: ‘#3D9970’,
‘color’: ‘green’,
},
]
)If I replace maxvalue (‘filter_query’: ‘{Percentage} > maxvalue’) by a figure such as 4, it perfectly works, but I would like to highlight the max value of the whole column to make it flexible. In this case 120.
Looking forward to your feedback.
Thank you very much in advance
Posts: 2
Participants: 2






