Dear all,
I am trying to figure out how to set a filter for a fourth column I am using. It works fine if I use the “normal” way to generate a figure but if I am using the Figure Factory and create_gantt the transformation does not get applied. Here is my code:
df = []
source = []
for row in cursor:
df.append(dict(Task=row[0], Start=row[1] , Finish=row[2], Source=row[4],Description=row[3]))
source.append(row[3])
colors = {'70': 'rgb(220, 0, 0)',
'90': 'rgb(50, 168,82)',
'30': 'rgb(252, 165, 3)',
'80': 'rgb(0, 0, 0)',
'00': 'rgb(102, 0, 255)'
}
#df.append()
fig = ff.create_gantt(df,colors=colors, showgrid_x=True, showgrid_y=True, index_col="Source", show_colorbar=True, group_tasks=True, bar_width=0.4, height=900,
data=[dict(transforms =[dict(
meta=source,
transforms = [dict(
type = "filter",
target = "Description",
operation = "=",
value = None
)
]
)])
])
fig.update_layout(
updatemenus=[
dict(
buttons=list([
dict(
args=[{"transforms[0].enabled": False}],
label="All",
method="restyle"
),
dict(
args=[{"transforms[0].value": "Value1"}],
label="Value1",
method="restyle"
),
dict(
args=[{"transforms[0].value": "Value2"}],
label="Value2",
method="restyle"
),
dict(
args=[{"transforms[0].value": "Value3"}],
label="Value3",
method="restyle"
),
]),
direction="down",
pad={"r": 10, "t": 10},
showactive=True,
x=0.1,
xanchor="left",
y=1.1,
yanchor="top"
),
]
)
fig.update_xaxes(tickson="labels")
fig.show()
The “Description” field contains the values that I want to filter.
Another question: How can I disable the filter for one dropdown (in this example for “All”) but activate it for the others?