Skip to content
Snippets Groups Projects
Commit dacaccf3 authored by Hamish Graham's avatar Hamish Graham
Browse files

updated pandas_bokeh.py

parent 027a8d67
No related branches found
No related tags found
No related merge requests found
Pipeline #2973503 failed
...@@ -3,7 +3,7 @@ import tree_maker as tm ...@@ -3,7 +3,7 @@ import tree_maker as tm
from pandas import DataFrame from pandas import DataFrame
from bokeh.layouts import column from bokeh.layouts import column
from bokeh.models import ColumnDataSource, Slider, WheelZoomTool, BoxZoomTool, Button from bokeh.models import ColumnDataSource, Slider, WheelZoomTool, BoxZoomTool, Button, PanTool
from bokeh.plotting import figure from bokeh.plotting import figure
from bokeh.themes import Theme from bokeh.themes import Theme
from bokeh.io import show, output_notebook from bokeh.io import show, output_notebook
...@@ -12,7 +12,10 @@ output_notebook() ...@@ -12,7 +12,10 @@ output_notebook()
#root = tm.tree_from_json(filename='/home/HPC/sterbini/DA_study_example/study_000/tree.json') #root = tm.tree_from_json(filename='/home/HPC/sterbini/DA_study_example/study_000/tree.json')
def bkapp(doc): def bkapp(doc, root, last_key, choose_color):
"""
This creates an interactive plot showing a tree of jobs in a 'flower' shape.
"""
global my_df global my_df
global source global source
...@@ -29,12 +32,6 @@ def bkapp(doc): ...@@ -29,12 +32,6 @@ def bkapp(doc):
del my_df['handle'] del my_df['handle']
source = ColumnDataSource(data=my_df)
plot = figure(plot_width=400, plot_height=400, tools="lasso_select", title="Select Here")
plot.circle('x', 'y', source=source, alpha=0.6, color = 'color')
plot.add_tools(BoxZoomTool())
def callback(attr, index_list, _): def callback(attr, index_list, _):
global my_df global my_df
global my_df_selected global my_df_selected
...@@ -43,13 +40,25 @@ def bkapp(doc): ...@@ -43,13 +40,25 @@ def bkapp(doc):
def dummyfunction(): def dummyfunction():
global my_df global my_df
my_df = ps.update(my_df, 'completed', 'green') my_df = ps.update(my_df, last_key, choose_color)
dummyfunction()
source = ColumnDataSource(data=my_df)
TOOLTIPS = [
('index', "@index"),
('status', "@status"),
('path', "@path")
]
plot = figure(plot_width=400, plot_height=400, tools="lasso_select", title="Select Here", tooltips = TOOLTIPS)
plot.circle('x', 'y', source=source, alpha=0.6, color = 'color')
plot.add_tools(BoxZoomTool(), WheelZoomTool(), PanTool())
source.selected.on_change('indices', callback) source.selected.on_change('indices', callback)
button = Button(label="Update", button_type="success") button = Button(label="Update", button_type="success")
button.on_click(dummyfunction) button.on_click(dummyfunction)
doc.add_root(column(plot, button)) doc.add_root(column(plot, button))
show(bkapp, notebook_url='http://localhost:8102', port=8202) # notebook_url="http://localhost:8888" \ No newline at end of file
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment