Quantcast
Channel: 🎛️ Dash - Plotly Community Forum
Viewing all articles
Browse latest Browse all 6271

Returned a value having type `Figure` which is not JSON serializable

$
0
0

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

3 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 6271

Latest Images

Trending Articles



Latest Images