Closed Davide-sd closed 1 year ago
Hi! I try to reproduce your results. On 2.15.0 I didn't get error
AttributeError: 'Plot' object has no attribute 'widgets'
I got html fil without "hack"
fig.widgets = dict()
but when I'm opening a file I cannot see a blue chart there.
Hi @Davide-sd
That's not a final solution but I somehow figure out what is happening here.
In K3D every object is in fact a widget in ipywidgets. The same with k3d.plot. When you add object to plot you add in fact only a reference. That is resonable assumption - in k3d you can add the same object to two plots and you can expect that line:
obj.color = 0x00ff00
will change color to green in two plots at the same time, right?
So in your example holoviz panel is not aware about that and treat k3d as single widget. Because you are passing a fig to it (it is instance of k3d.plot) you save state only of plot.
How to "solve" this? By adding:
application.objects.extend([surface])
you will inform your appplication that you will have more than plot. And thats works. Output test-k3d-app.html contain object data and size of file increased. But application is trying to plot second widget too :/ and it showing a error on bottom:
So it is not perfect solution for sure. From technical js side:
class ObjectModel extends widgets.WidgetModel class PlotModel extends widgets.DOMWidgetModel
So if holoviz somehow recognize that not all widgets are "DOMWidgetModel" maybe can ommit them to display directly?
Description
I'm trying to generate an html file of an interactive application that uses holoviz panel for widgets and K3D for visualization. However, I'm encountering a problem.
What I Did
The command
pn.pane.Pane(fig, width=800)
is going to create apn.pane.IPyWidget
object, wrapping the actual plot: I believe that it does that because panel sees a K3D plot as an ipywidget. The wrapping pane is necessary to render the plot on the application.So far so good. Now, let say I want to save an html file of
application
:I believe that
pn.pane.IPyWidget
doesn't fully understand what a k3d plot actually is. Just for debugging purposes, I tried:Which saves the actual application, but without data for k3d plot. Here is a screenshot.
At this point I probably have to create a new
pn.pane
that better understands K3D plots. However, how can I retrieve the actual data? Alternatively, is there any way I can extend a K3D plot to informpn.pane.IPyWidget
that there is data to be saved?