mo.ui.altair_chart(chart) is not updating based on filtered data
At a glance
The community member is creating a simple Altair bar chart and wants to update it based on filtered data, but the chart is not getting updated. The comments suggest that the code is mutating the bar chart only in the function and not actually updating the global bar chart. The community members recommend removing the update_chart function and letting everything run reactively, as well as declaring the bar chart only once and having it depend on all the filters. One community member suggests removing the callback and letting Marimo handle updating the affected cells based on changing UI elements. Another community member has refactored the code as suggested but is now getting an error related to the filtered_data variable being defined in another cell. The community members suggest renaming the variable to resolve the issue.
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 elements
Hi @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) ]