Glad you got it working!
iplot won’t work for a callback-based interactive pie chart (or at least, it doesn’t when I change the example only to use iplot rather than VBox).
This is correct, when a
FigureWidget is displayed using
iplot, the resulting view is not an ipywidget and so the events can’t be synced back to the Python side. A
FigureWidget should be allowed to display itself (by being the last expression in an input cell), or it can be displayed using the
ipywidgets.display method (See https://ipywidgets.readthedocs.io/en/stable/examples/Widget%20Basics.html#display()).
it won’t work if I create the “pie” object with go.Pie instead of with fig.add_pie (as in: fig = go.FigureWidget([go.Pie(labels=labels, values=values)])).
What’s happening here is that traces are copied when they are passed to figure constructors. So you do need to add a trace to the figure and then access it in order for the callbacks to be synced up. As an alternative to using the
add_* methods, you can retrieve the trace from the figure’s
data property. E.g.
fig = go.FigureWidget([go.Pie(labels=labels, values=values)]))
pie = fig.data
Hope that helps clear things up a bit!