2017-09-01 27 views
1

代碼分爲兩類 - tablerepresentation.我使用散景進行繪圖。可以使用小部件但不能在相同功能下繪製(散景)

當我點擊一個小部件,它會創建一個類table並帶我去反對representation.get_dia(),這應該給我一個行和一個段落。從table

def update_on_button_click(): 
      print(final_data) 
      rep=representation(final_data) 
      rep.get_dia() 

get_dia()功能

代碼片段 -

def get_dia(self): 
      curdoc().clear() 
      from bokeh.models import Paragraph 
      p2 = Paragraph(text='Under Construction',width=200, height=100) 
      p1=figure() 
      p1.line([1,2,3],[1,2,3]) 
      curdoc().add_root(row(p2,p1)) 

的功能顯示在瀏覽器中的段落,但不是陰謀。

爲什麼會出現這種情況?

P.S如果我從table函數調用它,該圖是可見的。

回答

1
#from bokeh.plotting import figure --- adding this (even though I had added 
#this at the starting itself) 
def get_dia(self): 
     #curdoc().clear() --- And Removing this solves the problem 
     from bokeh.models import Paragraph 
     p2 = Paragraph(text='Under Construction',width=200, height=100) 
     p1=figure() 
     p1.line([1,2,3],[1,2,3]) 
     curdoc().add_root(row(p2,p1)) 
相關問題