Hello, thank you for making Bokeh, I have been using it for a couple years and find it very helpful. I was hoping to get some help with the CustomJS implementation for a standalone html dashboard I am writing. I would like the make standalone html files which display charts, descriptive paragraphs on the charts, and a community discussion. The charts and words work well, but I am at a loss on the discussion aspect. Very simply, I would like users to be able to add there own Div(text=“whatever they want”) to the dashboard. It seems like this is easily doable, but I am currently at a loss. Below is my vain attempt. I understand this would need a CustomJS implementation, but just dont understand the concept very well. Perhaps this is due to a lack of javascript experience. My example has the text input box, but once the user tabs out, I would like the text they entered to be transferred, or, “published”, to the “Discussion” Div variable and the page reloaded. Thank you for the help!
minimal example code:
from bokeh.io import show, output_file
from bokeh.models import CustomJS, TextAreaInput, Div#, Arrow, NormalHead
from bokeh.layouts import Spacer, row, column
#write the html ---------------------------------------------------------------
TestNotes = Div(text='<h2>Test Notes</h2><ul><li>Info on test conditions</li></ul></ul>')
Hypothesis = Div(text='<h2>Hypothesis</h2><ol><li>Info on hypothesis</li></ol>')
Results = Div(text='<h2>Results</h2><i>Figure A</i> shows the results')
Conclusions = Div(text='<h2>Conclusions</h2><ol><li>Some words about conclusions</ol>')
Discussion = Div(text='<h2>Discussion</h2><p>This is where user comments should display.</p>')
Comments = TextAreaInput(placeholder="please enter your thoughts here", value="", rows=6, title="Comments:")
Comments.js_on_change("value", CustomJS(code="""
console.log('Discussion: value=' + this.value, this.toString())
Discussion.change.emit();
"""))
#define variables necessary for output file------------------------------------
output_file('text_input.html', title='Text Input Test')
column1 = column([TestNotes, Results, Discussion], width=500)
column2 = column([Hypothesis, Conclusions, Comments], width=500)
page = row([column1, Spacer(width=50), column2])
#make the file-----------------------------------------------------------------
show(page)