Closed arky closed 3 months ago
As that error message tries to point out, shinywidgets
is only designed to work with ipywidgets
, and ipyvizzu
doesn't integrate with ipywidgets
.
ipyvizzu
does, however, implement a _repr_html_()
method, and as a result, can be rendered via shiny
's @render.ui
decorator.
Unfortunately, to get the example working, you also need to set display=DisplayTarget.MANUAL
in Chart()
:
import pandas as pd
from ipyvizzu import Chart, Config, Data, DisplayTarget
from shiny.express import input, render, ui
ui.panel_title("iPyVizzu Test")
@render.ui
def chart():
df = pd.read_csv("https://ipyvizzu.vizzuhq.com/latest/showcases/titanic/titanic.csv")
data = Data()
data.add_df(df)
chart = Chart(width="640px", height="360px", display=DisplayTarget.MANUAL)
chart.animate(data)
chart.animate(
Config(
{
"x": "Count",
"y": "Sex",
"label": "Count",
"title": "Passengers of the Titanic",
}
)
)
chart.animate(
Config(
{
"x": ["Count", "Survived"],
"label": ["Count", "Survived"],
"color": "Survived",
}
)
)
chart.animate(Config({"x": "Count", "y": ["Sex", "Survived"]}))
return chart
Closing this since, if there is anything to improve upon here, shinywidgets
isn't the right place for it.
Thank you @cpsievert That is really helpful
Description
Quick test to show iPyVizzu chart with py-shinywidget.
Don't know how to coerce <ipyvizzu.chart.Chart object at 0x7f0322007a30> into a ipywidget.Widget object. Instead of using shinywidgets to render this object, try using shiny's @render.ui decorator https://shiny.posit.co/py/api/ui.output_ui.html#shiny.ui.output_ui
What I Did
shinywidgets version: shiny 0.7.1 shinylive 0.2.2 shinywidgets 0.3.0
Python version: 3.10
Operating System: Ubuntu LTS