Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Click and Hover data not working for Plotly pie chart: not serializable #4354

Closed
MarcSkovMadsen opened this issue Jan 29, 2023 · 0 comments · Fixed by #4355
Closed

Click and Hover data not working for Plotly pie chart: not serializable #4354

MarcSkovMadsen opened this issue Jan 29, 2023 · 0 comments · Fixed by #4355
Labels
type: bug Something isn't correct or isn't working
Milestone

Comments

@MarcSkovMadsen
Copy link
Collaborator

MarcSkovMadsen commented Jan 29, 2023

I'm on the current main branch of Panel and using plotly 5.13.0. I'm working on #4350 and experience that I cannot get click_data or hover_data working for a Plotly Pie plot. When I look in the browser console after hovering or clicking the plot I see the error

Uncaught Error: [object Undefined] is not serializable

image

import pandas as pd
import param as pm
import panel as pn
import plotly.express as px

df = pd.DataFrame({"ticker": ["A", "B", "C"], "value": [1, 2, 3]})


def portfolio_distribution(_=None, data=df):
    """Returns the distribution of the portfolio"""
    portfolio_total = data["value"].sum()

    fig = px.pie(
        data,
        values="value",
        names="ticker",
        hole=0.3,
        title=f"Portfolio Total ${portfolio_total:,.0f}",       
    )
    fig.layout.autosize = True
    return fig


plot = pn.pane.Plotly(
    portfolio_distribution(),
    config={"responsive": True},
    sizing_mode="stretch_both",
)

pn.Column(
    plot.param.hover_data,
    plot.param.click_data,
    plot,
    height=800,
    sizing_mode="stretch_width",
).servable()
@MarcSkovMadsen MarcSkovMadsen added the type: bug Something isn't correct or isn't working label Jan 29, 2023
@MarcSkovMadsen MarcSkovMadsen added this to the v0.14.3 milestone Jan 29, 2023
@MarcSkovMadsen MarcSkovMadsen changed the title Plotly pie chart: Click and Hover data not working for Plotly pie chart: not serializable Jan 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't correct or isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant