hi every one,
i want to display a plot in dcc.Graph, but i have an error “returned a value having type Figure
which is not JSON serializable.”
@app.callback(
Output("products_rating", "figure"),
Input("third_categories", "value"),
)
def update_stats(third_category, options):
products = get_products(third_category, category)
# plot products rating
bins = [0, 1, 2, 3, 4, 5]
grouped = products['rating'].value_counts(bins=bins, sort=False).to_frame()
grouped.reset_index(inplace=True)
products_rating_figure = px.bar(grouped, x='index', y='rating')
return products_rating_figure