in Education by
Apologies if this question is answered elsewhere on StackOverflow, I did my best to search for an answer before posting this question. I am working to create a Flask-based web app using Bokeh for data visualization at work. I have had no problem embedding scatter/line plots using bokeh.embed.components and bokeh.plotting.figure. I would like to display the data which is being used to make the plot in a DataTable widget below the plot. Unfortunately, using components to generate a script and div does not seem to work for widgets. Components also seems to fail when using a column, row, or layout created with bokeh.layouts. The general layout of my code is a Python file, which contains my Flask app, and an HTML file which contains the layout of my webpage. The general layout of the Python file is below: from flask import Flask, render_template import pandas as pd import numpy as np from bokeh.models import ColumnDataSource from bokeh.models.widgets import DataTable, TableColumn from bokeh.plotting import figure from bokeh.layouts import widgetbox, column from bokeh.embed import components app = Flask(__name__) x = np.linspace(0, 2, 1000) y = np.sin(x) df = pd.DataFrame({"x": x, "y":y}) # Not sure how to provide sample data @app.route("/") def index(): p = figure() p.scatter(df['x'], df['y']) data_source = ColumnDataSource(df) columns = [ TableColumn(field="field1", title="Field 1"), TableColumn(field="field2", title="Field 2"), TableColumn(field="field3", title="Field 3"), ] data_table = DataTable(source=data_source, columns=columns) script, div = components(column(p, widgetbox(data_table))) return render_template('sample.html', script=script, div=div) The HTML template ("sample.html") would look something like the following: {{ script|safe }} {{ div|safe }} I've elected to use a simple sine wave as the sample data for this code, but in real life I am using an Excel file (pd.read_excel) to test the code before connecting the web app to a database. In the Python code, if I replace script, div = components(column(p, widgetbox(data_table)) with script, div = components(p) the code works perfectly. So, that leads me to believe that the problem is with embedding a widget or a layout of plots and widgets. Thanks in advance for any help that you might be able to provide. JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
For what it's worth I realized what was wrong with my original code. Apparently, one needs to link to the CSS and JS for bokeh-tables when using DataTables with components. Below are the relevant link and script tags.

Related questions

0 votes
    When I run my Dash app from the command line using export PYTHONPATH=./src/ && python ./src/pdv/ ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 6, 2022 in Education by JackTerrance
0 votes
    I'm using Flask with HTML and CSS. When this is possible: What do I have to write here to ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 12, 2022 in Education by JackTerrance
0 votes
    I'm using Flask with HTML and CSS. When this is possible: What do I have to write here to ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 10, 2022 in Education by JackTerrance
0 votes
    I want to disable the sort property in dataTable API. I use bsort:false to disable sorting from all ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 20, 2022 in Education by JackTerrance
0 votes
    I am looking for the best way to send large Numpy arrays (composed mainly of images) via Flask. ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 13, 2022 in Education by JackTerrance
0 votes
    I want to upload the file pdf to the folder but a file is not saved to a folder. I already read the ... .run(debug=True)``` Select the correct answer from above options...
asked Jan 19, 2022 in Education by JackTerrance
0 votes
    I would like to document in the shaded jar what maven artifacts actually end up in that shaded jar. ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 5, 2022 in Education by JackTerrance
0 votes
    According to my understanding of QDateEdit's API documentation it creates a widget for editing dates. The ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 22, 2022 in Education by JackTerrance
0 votes
    According to my understanding of QDateEdit's API documentation it creates a widget for editing dates. The ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 11, 2022 in Education by JackTerrance
0 votes
    According to my understanding of QDateEdit's API documentation it creates a widget for editing dates. The ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    I'm using const embed = new Discord.RichEmbed(); for my embeds. How do I reset the Embed values? ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 29, 2022 in Education by JackTerrance
0 votes
    I have some trouble to correctly embed images in html/php email. My .php file just sends out a ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 26, 2022 in Education by JackTerrance
0 votes
    I have some trouble to correctly embed images in html/php email. My .php file just sends out a ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 23, 2022 in Education by JackTerrance
0 votes
    How can you embed a Visualflow in a Visualforce page?...
asked Nov 11, 2020 in Technology by JackTerrance
0 votes
    I am using datatable with Laravel to order a response that i receive from an API I connect to the ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 23, 2022 in Education by JackTerrance
...