mo.ui.altair_chart(chart) is not updating based on filtered data
I am creating a simple Altair bar chart, want to update it based on a filtered data but it is not getting updated. here is the flow of my code:
6 Replies
can anyone please help me witht this
Can you include a minimal example? This notebook is rather long
the code is mutating
bar_chart
only in the function, and not actually updating the global bar_chart
.
i would remove the update_chart
function and instead let everything run reactively
it would reduce the amount of code too. you should only declare once:
and still have it depend on all of your filters
i won't be able to refactor your code, but you should remove the callback and instead let marimo handle updating the affected cells based on changing ui elementsHi @Myles Scolnick Thank you for the suggestion. I have now refactored the code as suggested by you but now I am getting "The variable 'filtered_data' was defined by another cell:"
when I do the filteration based on the date range e.g. filtered_data = filtered_data[
(filtered_data["request_date"] >= end_date_str)
& (filtered_data["request_date"] <= start_date_str)
]
you need to rename the variable