问题
i am trying to export a report as HTML using Bokeh with python. Can anybody tell me, why my code is not working? I tried to print a simple Div and succeeded, but as soon as i include plots, the browser still opens, but nothing is visible. Is it not possible to inherit Figure?
I reduced it to the relevant parts:
def export_html(self):
plots=[]
plots.append(PlotObject(self.plot_attributes[4]))
VisuLog(plots)
from bokeh.plotting import Figure, show, output_file
class VisuLog():
def __init__(self,plots):
self.plots = plots
filename="Report_"
output_file("visu_out\\"+ filename + ".html", title=filename)
show(self.plots) # open a browser
class PlotObject(Figure):
def __init__(self,plot_attributes):
super(PlotObject, self).__init__()
Thank you for your help.
回答1:
Try adding
__subtype__ = 'PlotObject'
__view_model__ = 'Plot'
to the body of the PlotObject
class.
But I would advise against extending Bokeh objects unless you want to provide some UI behavior by writing custom JavaScript/TypeScript implementation.
来源:https://stackoverflow.com/questions/61636793/plots-do-not-show-with-bokeh