thanks a lot for fast response, I am glad to post my code below. My bk_plotter.py like modified_doc(doc).py is so long, sorry for that.
···
###########################################
view.py
from datetime import datetime
from DataVisualizationWebApp import bk_plotter as bk_plter
from DataVisualizationWebApp import bk_bar_stacked as bk_bar__stacked_plter
from DataVisualizationWebApp import importdata as dataLoader
from flask import Flask, render_template, request
from DataVisualizationWebApp import app
from flask import Flask, render_template
from bokeh.embed import server_document
from bokeh.layouts import column
from bokeh.models import ColumnDataSource, Slider
from bokeh.plotting import figure, curdoc
from bokeh.server.server import Server
from bokeh.themes import Theme
from tornado.ioloop import IOLoop
from bokeh.io import curdoc
from bokeh.sampledata.sea_surface_temperature import sea_surface_temperature
from bokeh.client import pull_session
from werkzeug.contrib.fixers import ProxyFix
#paramater
@app.route(‘/’, methods=[‘GET’])
def bkapp_page():
"""Renders the home page."""
script = server_document('http://localhost:5006/bk_plotter')
return render_template("embed.html", script=script, template="Flask")
@app.route(‘/contact’)
def contact():
return bk_plter.plot_html()
@app.route(‘/about’)
def about():
return bk_bar__stacked_plter.plot_bar_stacked()
def bk_worker():
# Can't pass num_procs > 1 in this configuration. If you need to run multiple
# processes, see e.g. flask_gunicorn_embed.py
server = Server({'/bk_plotter': bk_plter.plot_doc}, io_loop=IOLoop(), allow_websocket_origin=["*"])
server.start()
server.io_loop.start()
##################################################################################
bk_plotter.py
Create a polynomial line graph with those arguments
import flask
from bokeh.models import FactorRange, Spacer
from bokeh.embed import components
from bokeh.plotting import figure
from bokeh.resources import INLINE
from bokeh.util.string import encode_utf8
import pandas as pd
from bokeh.io import curdoc
from bokeh.layouts import row, column, gridplot
from bokeh.models import ColumnDataSource, TapTool, OpenURL, VBar, Rect
from bokeh.models.widgets import PreText, Select, CheckboxGroup
from bokeh.themes import Theme
from bokeh import events
from bokeh.events import MouseEnter, Event, MouseLeave, Tap
from bokeh.models.widgets import Button, Div
#from DataVisualizationWebApp import importdata as dataLoader
from pandas import DataFrame
from bokeh.layouts import row, widgetbox
from bokeh.palettes import Spectral5
from bokeh.core.properties import value
from bokeh.io import show, output_file, output_notebook
from bokeh.layouts import layout
from bokeh.models import ColumnDataSource, VBar
from bokeh.plotting import figure
from bokeh.models import HoverTool, Range1d
from copy import deepcopy
from numpy import pi
from operator import add
from bokeh.models import Arrow, NormalHead, VeeHead, Text
from bokeh.models.callbacks import CustomJS
from bokeh.models.glyphs import Text, Line
import csv
from itertools import chain
import pypyodbc
rig_id_str = “rig_id”
job_id_str = ‘job_id’
crew_shift_str = ‘crew_shift’
well_selection_str = “well_section”
connection_type_str = “connection_type”
connection_phase_str = “connection_phase”
type_str = “type”
status_str = “status”
hole_depth_str = ‘hole_depth’
pre_slip_time_str = ‘pre_slip_time’
post_slip_time_str = “post_slip_time”
survey_time_str = “survey_time”
backream_time_str = “backream_time”
slip_to_slip_str = “slip_to_slip”
depth_ft_str = “depth_ft”
edr_depth_ft = ‘edr_depth_ft’
selected_rig = ‘’
selected_job = ‘’
def import_all_data():
all_connection_dict = {}
novos_connection_dict = {}
connection = pypyodbc.connect(‘Driver={SQL Server};’
‘Server=SQLWDBQ01;’
‘Database=NOVOS;’
‘uid=PDPerformance;’
‘pwd=pTepJ1281S9kpC’)
cursor = connection.cursor()
select_all_connection = (“SELECT * FROM all_connection”)
cursor.execute(select_all_connection)
desc = cursor.description
column_names = [col[0] for col in desc]
all_connection_dict = [dict(zip(column_names, row))
for row in cursor.fetchall()]
select_novos_connection = (“SELECT * FROM novos_connection”)
cursor.execute(select_novos_connection)
desc = cursor.description
column_names = [col[0] for col in desc]
novos_connection_dict = [dict(zip(column_names, row))
for row in cursor.fetchall()]
connection.close()
return all_connection_dict, novos_connection_dict
def plot_doc(doc):
all_connection_dict, novos_connection_dict = import_all_data()
all_connection_dict = {k: [dic[k] for dic in all_connection_dict] for k in all_connection_dict[0]}
novos_connection_dict = {k: [dic[k] for dic in novos_connection_dict] for k in novos_connection_dict[0]}
all_connection_table = pd.DataFrame.from_dict(all_connection_dict)
novos_connection_table = pd.DataFrame.from_dict(novos_connection_dict)
#menu bar
1. data
rigs_list = all_connection_table[rig_id_str].unique().tolist()
jobs_list = all_connection_table[job_id_str].unique().tolist()
crewshift_list = all_connection_table[crew_shift_str].unique().tolist()
#crewshift_list.insert(0, ’ ')
def nix(val, lst, columnName = ‘’):
global selected_rig
global rig_id_str
global job_id_str
all_connection_table = pd.DataFrame.from_dict(all_connection_dict)
if val == ‘’:
return [x for x in lst]
else:
target =
target.append(int(val))
target.append(‘’)
if columnName == ‘JobNumber’:
selected_rig = int(val)
rigs_query = “{} in @target”.format(rig_id_str)
selected_rig_table = all_connection_table.query(rigs_query)
jobs_list = selected_rig_table[job_id_str].unique().tolist()
return jobs_list
elif columnName == ‘CrewShift’:
selected_rig = str(selected_rig)
rigs_query = “{} in @selected_rig”.format(rig_id_str)
selected_rig_table = all_connection_table.query(rigs_query)
jobs_query = “{} in @target”.format(job_id_str)
selected_job_table = selected_rig_table.query(jobs_query)
crewShift_list = selected_job_table[crew_shift_str].unique().tolist()
return crewShift_list
def rigs_combx_change(attrname, old, new):
test_list = nix(new, jobs_list, ‘JobNumber’)
test_list = [str(x) for x in test_list]
jobs_combx.options = test_list
if len(test_list) > 0:
jobs_combx.value = test_list[0]
else:
jobs_combx.value = ‘0’
rig_mainplot_data = {}
rig_depth_list =
rig_mainplot_data, rig_depth_list = update()
rig_depth_list = [str(x) for x in rig_depth_list]
main_plot.x_range.factors =
main_plot.x_range.factors = rig_depth_list
mainplot_source.data[‘VBarTop’] =
mainplot_source.data[‘VBarBottom’] =
mainplot_source.data[‘VBarColors’] =
mainplot_source.data[‘VBarType’] =
mainplot_source.data[‘HoleDepth’] = [item if item in rig_depth_list else ‘-1’ for item in mainplot_data_all[‘HoleDepth’]]
mainplot_source.data[‘VBarTop’] = updateSourceData(‘VBarTop’, rig_mainplot_data, mainplot_source.data)
mainplot_source.data[‘VBarBottom’] = updateSourceData(‘VBarBottom’, rig_mainplot_data, mainplot_source.data)
mainplot_source.data[‘VBarColors’] = updateSourceData(‘VBarColors’, rig_mainplot_data, mainplot_source.data)
mainplot_source.data[‘VBarType’] = updateSourceData(‘VBarType’, rig_mainplot_data, mainplot_source.data)
rig, job = new, jobs_combx.value
global selected_rig
global selected_job
selected_rig = rig
selected_job = job
well_connection_colors, x, well_connnection_counts, well_connnection_data = update_well_selection_chart(all_connection_dict, rig, job)
well_connnection_source.data[‘colors’] = well_connection_colors
well_connnection_source.data[‘x’] = x
well_connnection_source.data[‘counts’] = well_connnection_counts
#20180620 start
update_pie_charts()
print (‘############ Test #############’)
#20180620 end
def updateSourceData(in_mainplot_data_type, in_mainplot_data, in_all_data):
in_mainplot_data_length = len(in_mainplot_data[in_mainplot_data_type])
new_list =
i = 0
for item in in_all_data[‘HoleDepth’]:
if item != ‘-1’:
if i >= in_mainplot_data_length:
if in_mainplot_data_type == ‘VBarColors’:
new_list.append(‘white’)
else:
new_list.append(‘’)
else:
var = in_mainplot_data[in_mainplot_data_type][i]
new_list.append(var)
i = i + 1
else:
if in_mainplot_data_type == ‘VBarColors’:
new_list.append(‘white’)
else:
new_list.append(‘’)
return new_list
def jobs_combx_change(attrname, old, new):
#crewshift_combx.options = nix(new, rigs_list, ‘CrewShift’)
#rigs_list = [str(x) for x in rigs_list]
crewShift_list = nix(new, rigs_list, ‘CrewShift’)
crewShift_list = [str(x) for x in crewShift_list]
crewshift_combx.options = crewShift_list
job_mainplot_data = {}
job_depth_list =
job_mainplot_data, job_depth_list = update()
job_depth_list = [str(x) for x in job_depth_list]
main_plot.x_range.factors =
main_plot.x_range.factors = job_depth_list
mainplot_source.data[‘VBarTop’] =
mainplot_source.data[‘VBarBottom’] =
mainplot_source.data[‘VBarColors’] =
mainplot_source.data[‘VBarType’] =
mainplot_source.data[‘HoleDepth’] = [item if item in job_depth_list else ‘-1’ for item in mainplot_data_all[‘HoleDepth’]]
mainplot_source.data[‘VBarTop’] = updateSourceData(‘VBarTop’, job_mainplot_data, mainplot_source.data)
mainplot_source.data[‘VBarBottom’] = updateSourceData(‘VBarBottom’, job_mainplot_data, mainplot_source.data)
mainplot_source.data[‘VBarColors’] = updateSourceData(‘VBarColors’, job_mainplot_data, mainplot_source.data)
mainplot_source.data[‘VBarType’] = updateSourceData(‘VBarType’, job_mainplot_data, mainplot_source.data)
rig, job = rigs_combx.value, new
global selected_rig
global selected_job
selected_rig = rig
selected_job = job
well_connection_colors, x, well_connnection_counts, well_connnection_data = update_well_selection_chart(all_connection_dict, rig, job)
well_connnection_source.data[‘colors’] = well_connection_colors
well_connnection_source.data[‘x’] = x
well_connnection_source.data[‘counts’] = well_connnection_counts
#20180620 start
update_pie_charts()
print (‘############ Test #############’)
#20180620 end
def crewshift_combx_change(attrname, old, new):
pass
#crewshift_combx.options = nix(new, rig_number_list, ‘Crewshift’)
def get_default_value(all_connection_dict, comboBx, selectedRig = ‘’, selectedJob = ‘’):
global rig_id_str
global job_id_str
global crew_shift_str
default_number = ‘’
comboBx_list =
all_connection_table = pd.DataFrame.from_dict(all_connection_dict)
if comboBx == ‘Rigs’:
comboBx_list = all_connection_table[rig_id_str].unique().tolist()
elif comboBx == ‘Jobs’:
target =
selectedRig = int(selectedRig)
target.append(selectedRig)
target.append(‘’)
rigs_query = “{} in @target”.format(rig_id_str)
selected_rig_table = all_connection_table.query(rigs_query)
comboBx_list = selected_rig_table[job_id_str].unique().tolist()
elif comboBx == ‘CrewShift’:
#TODO need to test
rigs_query = “{} in @selectedRig”.format(rig_id_str)
selected_rig_table = all_connection_table.query(rigs_query)
jobs_query = “{} in @selectedJob”.format(job_id_str)
selected_job_table = selected_rig_table.query(jobs_query)
comboBx_list = selected_job_table[crew_shift_str].unique().tolist()
comboBx_list.insert(0, ’ ')
maybe need logic to handle no records in table. it is 0
if len(comboBx_list) >= 1:
default_number = comboBx_list[0]
return default_number, comboBx_list
default_rig_number, rigs_list = get_default_value(all_connection_dict, comboBx = ‘Rigs’,)
default_rig_number = str(default_rig_number)
rigs_list = [str(item) for item in rigs_list]
rigs_combx = Select(title=‘Rigs:’, value=default_rig_number, width=120, options=nix(‘’, rigs_list))
rigs_combx.on_change(‘value’, rigs_combx_change)
default_job_number, jobs_list = get_default_value(all_connection_dict, comboBx = ‘Jobs’, selectedRig = rigs_combx.value)
default_job_number = str(default_job_number)
jobs_list = [str(item) for item in jobs_list]
jobs_combx = Select(title=‘Jobs:’, value=default_job_number, width=120, options=nix(‘’, jobs_list))
jobs_combx.on_change(‘value’, jobs_combx_change)
default_crew, crewshift_list = get_default_value(all_connection_dict, comboBx = ‘CrewShift’, selectedRig = rigs_combx.value, selectedJob = jobs_combx.value)
default_crew = str(default_crew)
crewshift_list = [str(item) for item in crewshift_list]
crewshift_combx = Select(title=‘CrewShift:’, value=default_crew, width=120, options=nix(‘’, crewshift_list))
crewshift_combx.on_change(‘value’, crewshift_combx_change)
#size.on_change(‘value’, update)
global selected_rig
selected_rig = rigs_combx.value
global selected_job
selected_job = jobs_combx.value
2. checkbox group
checkbox_group_1 = CheckboxGroup(
labels=[“Build”, “Lateral”, “Vertical”], active=, name = ‘wellSelection’)
checkbox_group_2 = CheckboxGroup(
labels=[“Driller”, “Novos”, “Hybrid”], active=, name = ‘connectionType’)
checkbox_group_3 = CheckboxGroup(
labels=[“B2S”, “S2S”, “S2B”, “Survey”, “BackReam”], active=, name = ‘connectionPhase’)
3. plot
subplot = figure(x_range = [0, 50], y_range = [0, 30], plot_width=100, plot_height=50, toolbar_location=None, sizing_mode=‘scale_both’)
subplot_height = 50
subplot_weight = 190
#controls = row(children=[rigs_combx, jobs_combx, crewshift_combx], sizing_mode=‘scale_width’)
#row_1 = row(controls, sizing_mode=‘scale_width’)
#controls = widgetbox([x, y, color, size], width=200)
def add_misseditems(in_dict):
if ‘Driller’ in in_dict:
pass
else:
in_dict[‘Driller’] = 0
if ‘Hybrid’ in in_dict:
pass
else:
in_dict[‘Hybrid’] = 0
if ‘Novos’ in in_dict:
pass
else:
in_dict[‘Novos’] = 0
return in_dict
def update_well_selection_chart(all_connection_dict, rig = -1, job = -1):
#TODO:
#create a function to get selected jobs table
#need logic to handle rig == -1 and job == -1
global rig_id_str
global job_id_str
global well_selection_str
global connection_type_str
all_connection_table = {}
all_connection_table = pd.DataFrame.from_dict(all_connection_dict)
rig_target =
rig_target.append(int(rig))
rig_target.append(‘’)
rigs_query = “{} in @rig_target”.format(rig_id_str)
selected_rig_table = all_connection_table.query(rigs_query)
job_target =
job_target.append(int(job))
job_target.append(‘’)
jobs_query = “{} in @job_target”.format(job_id_str)
selected_job_table = selected_rig_table.query(jobs_query)
#1st chart
build_query = ‘{} in [“Build”,]’.format(well_selection_str)
build_table = selected_job_table.query(build_query)
build_count = build_table.groupby(connection_type_str).size().to_dict()
vertical_query = ‘{} in [“Vertical”,]’.format(well_selection_str)
vertical_table = selected_job_table.query(vertical_query)
vertical_count = vertical_table.groupby(connection_type_str).size().to_dict()
lateral_query = ‘{} in [“Lateral”,]’.format(well_selection_str)
lateral_table = selected_job_table.query(lateral_query)
lateral_count = lateral_table.groupby(connection_type_str).size().to_dict()
build_count = add_misseditems(build_count)
vertical_count = add_misseditems(vertical_count)
lateral_count = add_misseditems(lateral_count)
drilling_connection_by_well_selection = {“Build” : build_count, “Vertical” : vertical_count, “Lateral” : lateral_count }
well_selection_list = [“Vertical”, “Build”, “Lateral”]
collection_type_keys_list = list(build_count.keys())
well_connnection_data = {‘well_selection’: well_selection_list,
‘Driller’ : [vertical_count[‘Driller’], build_count[‘Driller’], lateral_count[‘Driller’]],
‘Hybrid’ : [vertical_count[‘Hybrid’], build_count[‘Hybrid’], lateral_count[‘Hybrid’]],
‘Novos’ : [vertical_count[‘Novos’], build_count[‘Novos’], lateral_count[‘Novos’]],
}
x = [ (well_selection, collection_type) for well_selection in well_selection_list for collection_type in collection_type_keys_list]
counts = sum(zip(well_connnection_data[‘Driller’], well_connnection_data[‘Hybrid’], well_connnection_data[‘Novos’]), ())
m_colors = [“blue”, “red”, “yellow”, “green”, “orange”]
def generate_well_selectin_colors(m_colors ,in_well_connnection_data):
colors_list =
driller_list = in_well_connnection_data[‘Driller’]
driller_list_length = len(driller_list)
for item in in_well_connnection_data[‘well_selection’]:
colors_list += m_colors[:driller_list_length]
return colors_list
#well_connection_colors = [“blue” for item in well_connnection_data[‘Driller’]] + [“red” for item in well_connnection_data[‘Hybrid’]] + [“yellow” for item in well_connnection_data[‘Novos’]]
well_connection_colors = generate_well_selectin_colors(m_colors, well_connnection_data)
return well_connection_colors, x, counts, well_connnection_data
rig, job = rigs_combx.value, jobs_combx.value
well_connection_colors, x, well_connnection_counts, well_connnection_data = update_well_selection_chart(all_connection_dict, rig, job)
well_connnection_source = ColumnDataSource(data=dict(colors=well_connection_colors, x = x, counts=well_connnection_counts))
well_connection_chart = figure(x_range=FactorRange(*x), plot_width = 600, plot_height=600, sizing_mode=‘scale_both’, title=“Drilling Connection Breakdown By Well Section”,)
well_connection_chart.vbar(x=‘x’, width=0.1, bottom=0, top=‘counts’, color=‘colors’, source=well_connnection_source)
well_connection_chart.title.align = ‘center’
well_connection_chart.toolbar.active_drag = None
well_connection_chart.toolbar.logo = None
well_connection_chart.toolbar_location = None
well_connection_chart.y_range.start = 0
well_connection_chart.x_range.range_padding = 0.1
well_connection_chart.xaxis.major_label_orientation = 1
well_connection_chart.xgrid.grid_line_color = None
well_connection_chart.min_border_left = 0
well_connection_chart.min_border_right = 0
well_connection_chart.min_border_top = 0
well_connection_chart.min_border_bottom = 0
for well_item in well_connnection_data[‘well_selection’]:
for sub_item in well_connnection_data[‘Driller’]:
well_connection_chart.add_tools(HoverTool(tooltips=[(str(well_item), “@counts”)]))
#need to test
def update_pie_charts():
selected_job_table = get_novos_job_table()
update_offBottom_pie_chart(selected_job_table)
update_clearBit_pie_chart(selected_job_table)
update_setWeight_pie_chart(selected_job_table)
update_setBoxHeight_pie_chart(selected_job_table)
update_unWeightBit_pie_chart(selected_job_table)
update_cleanHole_pie_chart(selected_job_table)
update_addStand_pie_chart(selected_job_table)
update_takeWeight_pie_chart(selected_job_table)
update_flowSetpoint_pie_chart(selected_job_table)
update_rotateDrill_pie_chart(selected_job_table)
update_tagBottom_pie_chart(selected_job_table)
def update_offBottom_pie_chart(selected_job_table):
global connection_phase_str
global type_str
global status_str
connection_phase_query = ‘{} in [“B2S”,]’.format(connection_phase_str)
type_query = ‘{} in [“OffBottom”,]’.format(type_str)
status_query = ‘{} in [“Canceled”, “Completed”]’.format(status_str)
offBottom_table = selected_job_table.query(connection_phase_query).query(type_query).query(status_query)
offBottom_pie_dict = offBottom_table.groupby(status_str).size().to_dict()
offBottom_pie_legend = list(offBottom_pie_dict.keys())
starts, ends = calculate_percentage(offBottom_pie_dict)
offbottom_pie_source.data[‘start_angle’] = starts
offbottom_pie_source.data[‘end_angle’] = ends
offbottom_pie_source.data[‘legend’] = offBottom_pie_legend
def update_clearBit_pie_chart(selected_job_table):
global connection_phase_str
global type_str
global status_str
connection_phase_query = ‘{} in [“B2S”,]’.format(connection_phase_str)
type_query = ‘{} in [“ClearBit”,]’.format(type_str)
status_query = ‘{} in [“Canceled”, “Completed”]’.format(status_str)
clearBit_table = selected_job_table.query(connection_phase_query).query(type_query).query(status_query)
clearBit_pie_dict = clearBit_table.groupby(status_str).size().to_dict()
clearBit_pie_legend = list(clearBit_pie_dict.keys())
starts, ends = calculate_percentage(clearBit_pie_dict)
clearBit_pie_source.data[‘start_angle’] = starts
clearBit_pie_source.data[‘end_angle’] = ends
clearBit_pie_source.data[‘legend’] = clearBit_pie_legend
def update_setWeight_pie_chart(selected_job_table):
global connection_phase_str
global type_str
global status_str
connection_phase_query = ‘{} in [“B2S”,]’.format(connection_phase_str)
type_query = ‘{} in [“SetWeight”,]’.format(type_str)
status_query = ‘{} in [“Canceled”, “Completed”, “Failed”]’.format(status_str)
setWeight_table = selected_job_table.query(connection_phase_query).query(type_query).query(status_query)
setWeight_pie_dict = setWeight_table.groupby(status_str).size().to_dict()
setWeight_pie_legend = list(setWeight_pie_dict.keys())
starts, ends = calculate_percentage(setWeight_pie_dict)
setWeight_pie_source.data[‘start_angle’] = starts
setWeight_pie_source.data[‘end_angle’] = ends
setWeight_pie_source.data[‘legend’] = setWeight_pie_legend
def update_setBoxHeight_pie_chart(selected_job_table):
global connection_phase_str
global type_str
global status_str
connection_phase_query = ‘{} in [“B2S”,]’.format(connection_phase_str)
type_query = ‘{} in [“SetBoxHeight”,]’.format(type_str)
status_query = ‘{} in [“Canceled”, “Completed”]’.format(status_str)
setBoxHeight_table = selected_job_table.query(connection_phase_query).query(type_query).query(status_query)
setBoxHeight_pie_dict = setBoxHeight_table.groupby(status_str).size().to_dict()
setBoxHeight_pie_legend = list(setBoxHeight_pie_dict.keys())
starts, ends = calculate_percentage(setBoxHeight_pie_dict)
setBoxHeight_pie_source.data[‘start_angle’] = starts
setBoxHeight_pie_source.data[‘end_angle’] = ends
setBoxHeight_pie_source.data[‘legend’] = setBoxHeight_pie_legend
def update_unWeightBit_pie_chart(selected_job_table):
global connection_phase_str
global type_str
global status_str
connection_phase_query = ‘{} in [“B2S”,]’.format(connection_phase_str)
type_query = ‘{} in [“UnWeightBit”,]’.format(type_str)
status_query = ‘{} in [“Canceled”, “Completed”]’.format(status_str)
unWeightBit_table = selected_job_table.query(connection_phase_query).query(type_query).query(status_query)
unWeightBit_pie_dict = unWeightBit_table.groupby(status_str).size().to_dict()
unWeightBit_pie_legend = list(unWeightBit_pie_dict.keys())
starts, ends = calculate_percentage(unWeightBit_pie_dict)
unWeightBit_pie_source.data[‘start_angle’] = starts
unWeightBit_pie_source.data[‘end_angle’] = ends
unWeightBit_pie_source.data[‘legend’] = unWeightBit_pie_legend
def update_cleanHole_pie_chart(selected_job_table):
global connection_phase_str
global type_str
global status_str
connection_phase_query = ‘{} in [“B2S”,]’.format(connection_phase_str)
type_query = ‘{} in [“CleanHole”,]’.format(type_str)
status_query = ‘{} in [“Canceled”, “Completed”]’.format(status_str)
cleanHole_table = selected_job_table.query(connection_phase_query).query(type_query).query(status_query)
cleanHole_pie_dict = cleanHole_table.groupby(status_str).size().to_dict()
cleanHole_pie_legend = list(cleanHole_pie_dict.keys())
starts, ends = calculate_percentage(cleanHole_pie_dict)
cleanHole_pie_source.data[‘start_angle’] = starts
cleanHole_pie_source.data[‘end_angle’] = ends
cleanHole_pie_source.data[‘legend’] = cleanHole_pie_legend
def update_addStand_pie_chart(selected_job_table):
global connection_phase_str
global type_str
global status_str
connection_phase_query = ‘{} in [“S2B”,]’.format(connection_phase_str)
type_query = ‘{} in [“AddStand”,]’.format(type_str)
status_query = ‘{} in [“Canceled”, “Completed”, “Failed”]’.format(status_str)
addStand_table = selected_job_table.query(connection_phase_query).query(type_query).query(status_query)
addStand_pie_dict = addStand_table.groupby(status_str).size().to_dict()
addStand_pie_legend = list(addStand_pie_dict.keys())
starts, ends = calculate_percentage(addStand_pie_dict)
addStand_pie_source.data[‘start_angle’] = starts
addStand_pie_source.data[‘end_angle’] = ends
addStand_pie_source.data[‘legend’] = addStand_pie_legend
def update_takeWeight_pie_chart(selected_job_table):
global connection_phase_str
global type_str
global status_str
connection_phase_query = ‘{} in [“S2B”,]’.format(connection_phase_str)
type_query = ‘{} in [“TakeWeight”,]’.format(type_str)
status_query = ‘{} in [“Canceled”, “Completed”, “Failed”]’.format(status_str)
takeWeight_table = selected_job_table.query(connection_phase_query).query(type_query).query(status_query)
takeWeight_pie_dict = takeWeight_table.groupby(status_str).size().to_dict()
takeWeight_pie_legend = list(takeWeight_pie_dict.keys())
starts, ends = calculate_percentage(takeWeight_pie_dict)
takeWeight_pie_source.data[‘start_angle’] = starts
takeWeight_pie_source.data[‘end_angle’] = ends
takeWeight_pie_source.data[‘legend’] = takeWeight_pie_legend
def update_flowSetpoint_pie_chart(selected_job_table):
global connection_phase_str
global type_str
global status_str
connection_phase_query = ‘{} in [“S2B”,]’.format(connection_phase_str)
type_query = ‘{} in [“FlowSetpoint”,]’.format(type_str)
status_query = ‘{} in [“Canceled”, “Failed”]’.format(status_str)
flowSetpoint_table = selected_job_table.query(connection_phase_query).query(type_query).query(status_query)
flowSetpoint_pie_dict = flowSetpoint_table.groupby(status_str).size().to_dict()
flowSetpoint_pie_legend = list(flowSetpoint_pie_dict.keys())
starts, ends = calculate_percentage(flowSetpoint_pie_dict)
flowSetpoint_pie_source.data[‘start_angle’] = starts
flowSetpoint_pie_source.data[‘end_angle’] = ends
flowSetpoint_pie_source.data[‘legend’] = flowSetpoint_pie_legend
def update_rotateDrill_pie_chart(selected_job_table):
global connection_phase_str
global type_str
global status_str
connection_phase_query = ‘{} in [“S2B”,]’.format(connection_phase_str)
type_query = ‘{} in [“RotateDrill”,]’.format(type_str)
status_query = ‘{} in [“Canceled”, “Completed”, “Failed”]’.format(status_str)
rotateDrill_table = selected_job_table.query(connection_phase_query).query(type_query).query(status_query)
rotateDrill_pie_dict = rotateDrill_table.groupby(status_str).size().to_dict()
rotateDrill_pie_legend = list(rotateDrill_pie_dict.keys())
starts, ends = calculate_percentage(rotateDrill_pie_dict)
rotateDrill_pie_source.data[‘start_angle’] = starts
rotateDrill_pie_source.data[‘end_angle’] = ends
rotateDrill_pie_source.data[‘legend’] = rotateDrill_pie_legend
def update_tagBottom_pie_chart(selected_job_table):
global connection_phase_str
global type_str
global status_str
connection_phase_query = ‘{} in [“S2B”,]’.format(connection_phase_str)
type_query = ‘{} in [“TagBottom”,]’.format(type_str)
status_query = ‘{} in [“Canceled”, “Completed”, “Failed”]’.format(status_str)
tagBottom_table = selected_job_table.query(connection_phase_query).query(type_query).query(status_query)
tagBottom_pie_dict = tagBottom_table.groupby(status_str).size().to_dict()
tagBottom_pie_legend = list(tagBottom_pie_dict.keys())
starts, ends = calculate_percentage(tagBottom_pie_dict)
tagBottom_pie_source.data[‘start_angle’] = starts
tagBottom_pie_source.data[‘end_angle’] = ends
tagBottom_pie_source.data[‘legend’] = tagBottom_pie_legend
def calculate_percentage(in_dict):
in_list = in_dict.values()
total = sum(in_list)
percents = [value * 1. / total for value in in_list]
percents = [0.0] + percents
percents[-1] = 1.0
starts = [p2pi for p in percents[:-1]]
ends = [p2pi for p in percents[1:]]
return starts, ends
2nd pie chart
data
#TODO: rename it to get_job_table
could be a function
def get_novos_job_table():
global selected_rig
global selected_job
global rig_id_str
global job_id_str
rig = selected_rig
job = selected_job
rig_target =
rig_target.append(int(rig))
rig_target.append(‘’)
rigs_query = “{} in @rig_target”.format(rig_id_str)
selected_rig_table = novos_connection_table.query(rigs_query)
job_target =
job_target.append(int(job))
job_target.append(‘’)
jobs_query = “{} in @job_target”.format(job_id_str)
selected_job_table = selected_rig_table.query(jobs_query)
return selected_job_table
selected_rig_table = get_novos_job_table()
connection_phase_query = ‘{} in [“B2S”,]’.format(connection_phase_str)
type_query = ‘{} in [“OffBottom”,]’.format(type_str)
status_query = ‘{} in [“Canceled”, “Completed”]’.format(status_str)
offBottom_table = selected_rig_table.query(connection_phase_query).query(type_query).query(status_query)
offBottom_pie_dict = offBottom_table.groupby(status_str).size().to_dict()
offBottom_pie_legend = list(offBottom_pie_dict.keys())
starts, ends = calculate_percentage(offBottom_pie_dict)
pie_colors = [“red”, “green”, “blue”, “orange”, “yellow”]
offbottom_pie_colors = [“red”, “green”]
offbottom_pie_source = ColumnDataSource(data=dict(colors=offbottom_pie_colors, start_angle = starts, end_angle=ends, legend=offBottom_pie_legend))
pie offbottom
offbottom_pie = figure(x_range=(-0.9, 1), y_range=(-0.6, 0.6), plot_width = 200, plot_height = 180, title=“Off Bottom”)
#for i in range(len(starts)):
offbottom_pie.wedge(x=-0.25 , y=0, radius=.5, start_angle=starts[i], end_angle=ends[i], color=pie_colors[i], legend=offBottom_pie_legend[i])
offbottom_pie.wedge(x=-0.25 , y=0, radius=.5, start_angle=‘start_angle’, end_angle=‘end_angle’, color=‘colors’, legend=‘legend’, source=offbottom_pie_source)
offbottom_pie.title.align = ‘center’
offbottom_pie.xaxis.visible = None
offbottom_pie.yaxis.visible = None
offbottom_pie.toolbar.active_drag = None
offbottom_pie.toolbar.logo = None
offbottom_pie.toolbar_location = None
offbottom_pie.min_border_left = 0
offbottom_pie.min_border_right = 0
offbottom_pie.min_border_top = 0
offbottom_pie.min_border_bottom = 0
offbottom_pie.legend.location = “center_right”
offbottom_pie.legend.label_text_font_size = ‘6pt’
offbottom_pie.legend.glyph_height = 10
offbottom_pie.legend.glyph_width = 10
offbottom_pie.legend.background_fill_alpha = 0
offbottom_pie.legend.border_line_alpha = 0
offbottom_pie.legend.padding = 0
offbottom_pie.legend.spacing = 1
pie clearbit
connection_phase_query = ‘{} in [“B2S”,]’.format(connection_phase_str)
type_query = ‘{} in [“ClearBit”,]’.format(type_str)
status_query = ‘{} in [“Canceled”, “Completed”]’.format(status_str)
clearBit_table = selected_rig_table.query(connection_phase_query).query(type_query).query(status_query)
clearBit_pie_dict = clearBit_table.groupby(status_str).size().to_dict()
clearBit_pie_legend = list(clearBit_pie_dict.keys())
starts, ends = calculate_percentage(clearBit_pie_dict)
clearBit_pie_colors = [“red”, “green”]
clearBit_pie_source = ColumnDataSource(data=dict(colors=clearBit_pie_colors, start_angle = starts, end_angle=ends, legend=clearBit_pie_legend))
clearBit_pie = figure(x_range=(-0.9, 1), y_range=(-0.6, 0.6), plot_width = 200, plot_height = 180, title=“clear Bit”)
#for i in range(len(starts)):
clearBit_pie.wedge(x=-0.25 , y=0, radius=.5, start_angle=starts[i], end_angle=ends[i], color=pie_colors[i], legend=clearBit_pie_legend[i])
clearBit_pie.wedge(x=-0.25 , y=0, radius=.5, start_angle = ‘start_angle’, end_angle = ‘end_angle’, color = ‘colors’, legend = ‘legend’, source = clearBit_pie_source)
clearBit_pie.title.align = ‘center’
clearBit_pie.xaxis.visible = None
clearBit_pie.yaxis.visible = None
clearBit_pie.toolbar.active_drag = None
clearBit_pie.toolbar.logo = None
clearBit_pie.toolbar_location = None
clearBit_pie.min_border_left = 0
clearBit_pie.min_border_right = 0
clearBit_pie.min_border_top = 0
clearBit_pie.min_border_bottom = 0
clearBit_pie.legend.location = “center_right”
clearBit_pie.legend.label_text_font_size = ‘6pt’
clearBit_pie.legend.glyph_height = 10
clearBit_pie.legend.glyph_width = 10
clearBit_pie.legend.background_fill_alpha = 0
clearBit_pie.legend.border_line_alpha = 0
clearBit_pie.legend.padding = 0
clearBit_pie.legend.spacing = 1
pie setWeight
connection_phase_query = ‘{} in [“B2S”,]’.format(connection_phase_str)
type_query = ‘{} in [“SetWeight”,]’.format(type_str)
status_query = ‘{} in [“Canceled”, “Completed”, “Failed”]’.format(status_str)
setWeight_table = selected_rig_table.query(connection_phase_query).query(type_query).query(status_query)
setWeight_pie_dict = setWeight_table.groupby(status_str).size().to_dict()
setWeight_pie_legend = list(setWeight_pie_dict.keys())
starts, ends = calculate_percentage(setWeight_pie_dict)
setWeight_pie_colors = [“red”, “green”, “blue”]
setWeight_pie_source = ColumnDataSource(data=dict(colors=setWeight_pie_colors, start_angle = starts, end_angle=ends, legend=setWeight_pie_legend))
setWeight_pie = figure(x_range=(-0.9, 1), y_range=(-0.6, 0.6), plot_width = 200, plot_height = 180, title=“Set Weight”)
#for i in range(len(starts)):
setWeight_pie.wedge(x=-0.25 , y=0, radius=.5, start_angle=starts[i], end_angle=ends[i], color=pie_colors[i], legend=setWeight_pie_legend[i])
setWeight_pie.wedge(x=-0.25 , y=0, radius=.5, start_angle=‘start_angle’, end_angle=‘end_angle’, color=‘colors’, legend=‘legend’, source=setWeight_pie_source)
setWeight_pie.title.align = ‘center’
setWeight_pie.xaxis.visible = None
setWeight_pie.yaxis.visible = None
setWeight_pie.toolbar.active_drag = None
setWeight_pie.toolbar.logo = None
setWeight_pie.toolbar_location = None
setWeight_pie.min_border_left = 0
setWeight_pie.min_border_right = 0
setWeight_pie.min_border_top = 0
setWeight_pie.min_border_bottom = 0
setWeight_pie.legend.location = “center_right”
setWeight_pie.legend.label_text_font_size = ‘6pt’
setWeight_pie.legend.glyph_height = 10
setWeight_pie.legend.glyph_width = 10
setWeight_pie.legend.background_fill_alpha = 0
setWeight_pie.legend.border_line_alpha = 0
setWeight_pie.legend.padding = 0
setWeight_pie.legend.spacing = 1
pie setBoxHeight
connection_phase_query = ‘{} in [“B2S”,]’.format(connection_phase_str)
type_query = ‘{} in [“SetBoxHeight”,]’.format(type_str)
status_query = ‘{} in [“Canceled”, “Completed”]’.format(status_str)
setBoxHeight_table = selected_rig_table.query(connection_phase_query).query(type_query).query(status_query)
setBoxHeight_pie_dict = setBoxHeight_table.groupby(status_str).size().to_dict()
setBoxHeight_pie_legend = list(setBoxHeight_pie_dict.keys())
starts, ends = calculate_percentage(setBoxHeight_pie_dict)
setBoxHeight_pie_colors = [“red”, “green”]
setBoxHeight_pie_source = ColumnDataSource(data=dict(colors = setBoxHeight_pie_colors, start_angle = starts, end_angle=ends, legend = setBoxHeight_pie_legend))
setBoxHeight_pie = figure(x_range=(-0.9, 1), y_range=(-0.6, 0.6), plot_width = 200, plot_height = 180, title=“Set Box Height”)
#for i in range(len(starts)):
setBoxHeight_pie.wedge(x=-0.25 , y=0, radius=.5, start_angle=starts[i], end_angle=ends[i], color=pie_colors[i], legend=setBoxHeight_pie_legend[i])
setBoxHeight_pie.wedge(x=-0.25 , y=0, radius=.5, start_angle=‘start_angle’, end_angle=‘end_angle’, color=‘colors’, legend=‘legend’, source = setBoxHeight_pie_source)
setBoxHeight_pie.title.align = ‘center’
setBoxHeight_pie.xaxis.visible = None
setBoxHeight_pie.yaxis.visible = None
setBoxHeight_pie.toolbar.active_drag = None
setBoxHeight_pie.toolbar.logo = None
setBoxHeight_pie.toolbar_location = None
setBoxHeight_pie.min_border_left = 0
setBoxHeight_pie.min_border_right = 0
setBoxHeight_pie.min_border_top = 0
setBoxHeight_pie.min_border_bottom = 0
setBoxHeight_pie.legend.location = “center_right”
setBoxHeight_pie.legend.label_text_font_size = ‘6pt’
setBoxHeight_pie.legend.glyph_height = 10
setBoxHeight_pie.legend.glyph_width = 10
setBoxHeight_pie.legend.background_fill_alpha = 0
setBoxHeight_pie.legend.border_line_alpha = 0
setBoxHeight_pie.legend.padding = 0
setBoxHeight_pie.legend.spacing = 1
pie unWeightBit
connection_phase_query = ‘{} in [“B2S”,]’.format(connection_phase_str)
type_query = ‘{} in [“UnWeightBit”,]’.format(type_str)
status_query = ‘{} in [“Canceled”, “Completed”]’.format(status_str)
unWeightBit_table = selected_rig_table.query(connection_phase_query).query(type_query).query(status_query)
unWeightBit_pie_dict = unWeightBit_table.groupby(status_str).size().to_dict()
unWeightBit_pie_legend = list(unWeightBit_pie_dict.keys())
starts, ends = calculate_percentage(unWeightBit_pie_dict)
unWeightBit_pie_colors = [“red”, “green”]
unWeightBit_pie_source = ColumnDataSource(data=dict(colors=unWeightBit_pie_colors, start_angle = starts, end_angle=ends, legend=unWeightBit_pie_legend))
unWeightBit_pie = figure(x_range=(-0.9, 1), y_range=(-0.6, 0.6), plot_width = 200, plot_height = 180, title=“UnWeight Bit”)
#for i in range(len(starts)):
unWeightBit_pie.wedge(x=-0.25 , y=0, radius=.5, start_angle=starts[i], end_angle=ends[i], color=pie_colors[i], legend=unWeightBit_pie_legend[i])
unWeightBit_pie.wedge(x=-0.25 , y=0, radius=.5, start_angle=‘start_angle’, end_angle=‘end_angle’, color=‘colors’, legend=‘legend’, source = unWeightBit_pie_source)
unWeightBit_pie.title.align = ‘center’
unWeightBit_pie.xaxis.visible = None
unWeightBit_pie.yaxis.visible = None
unWeightBit_pie.toolbar.active_drag = None
unWeightBit_pie.toolbar.logo = None
unWeightBit_pie.toolbar_location = None
unWeightBit_pie.min_border_left = 0
unWeightBit_pie.min_border_right = 0
unWeightBit_pie.min_border_top = 0
unWeightBit_pie.min_border_bottom = 0
unWeightBit_pie.legend.location = “center_right”
unWeightBit_pie.legend.label_text_font_size = ‘6pt’
unWeightBit_pie.legend.glyph_height = 10
unWeightBit_pie.legend.glyph_width = 10
unWeightBit_pie.legend.background_fill_alpha = 0
unWeightBit_pie.legend.border_line_alpha = 0
unWeightBit_pie.legend.padding = 0
unWeightBit_pie.legend.spacing = 1
pie cleanHole
connection_phase_query = ‘{} in [“B2S”,]’.format(connection_phase_str)
type_query = ‘{} in [“CleanHole”,]’.format(type_str)
status_query = ‘{} in [“Canceled”, “Completed”]’.format(status_str)
cleanHole_table = selected_rig_table.query(connection_phase_query).query(type_query).query(status_query)
cleanHole_pie_dict = cleanHole_table.groupby(status_str).size().to_dict()
cleanHole_pie_legend = list(cleanHole_pie_dict.keys())
starts, ends = calculate_percentage(cleanHole_pie_dict)
cleanHole_pie_colors = [“red”, “green”]
cleanHole_pie_source = ColumnDataSource(data=dict(colors=cleanHole_pie_colors, start_angle = starts, end_angle=ends, legend=cleanHole_pie_legend))
cleanHole_pie = figure(x_range=(-0.9, 1), y_range=(-0.6, 0.6), plot_width = 200, plot_height = 180, title=“Clean Hole”)
#for i in range(len(starts)):
cleanHole_pie.wedge(x=-0.25 , y=0, radius=.5, start_angle=starts[i], end_angle=ends[i], color=pie_colors[i], legend=cleanHole_pie_legend[i])
cleanHole_pie.wedge(x=-0.25 , y=0, radius=.5, start_angle=‘start_angle’, end_angle=‘end_angle’, color=‘colors’, legend=‘legend’, source=cleanHole_pie_source)
cleanHole_pie.title.align = ‘center’
cleanHole_pie.xaxis.visible = None
cleanHole_pie.yaxis.visible = None
cleanHole_pie.toolbar.active_drag = None
cleanHole_pie.toolbar.logo = None
cleanHole_pie.toolbar_location = None
cleanHole_pie.min_border_left = 0
cleanHole_pie.min_border_right = 0
cleanHole_pie.min_border_top = 0
cleanHole_pie.min_border_bottom = 0
cleanHole_pie.legend.location = “center_right”
cleanHole_pie.legend.label_text_font_size = ‘6pt’
cleanHole_pie.legend.glyph_height = 10
cleanHole_pie.legend.glyph_width = 10
cleanHole_pie.legend.background_fill_alpha = 0
cleanHole_pie.legend.border_line_alpha = 0
cleanHole_pie.legend.padding = 0
cleanHole_pie.legend.spacing = 1
novos_connection_b2s_layout = gridplot([[offbottom_pie, clearBit_pie],
[setWeight_pie, setBoxHeight_pie],
[unWeightBit_pie, cleanHole_pie]],
plot_width=200, plot_height=200,
title=“haha”, toolbar_location = None)
pie addStand
connection_phase_query = ‘{} in [“S2B”,]’.format(connection_phase_str)
type_query = ‘{} in [“AddStand”,]’.format(type_str)
status_query = ‘{} in [“Canceled”, “Completed”, “Failed”]’.format(status_str)
addStand_table = selected_rig_table.query(connection_phase_query).query(type_query).query(status_query)
addStand_pie_dict = addStand_table.groupby(status_str).size().to_dict()
addStand_pie_legend = list(addStand_pie_dict.keys())
starts, ends = calculate_percentage(addStand_pie_dict)
addStand_pie_colors = [“red”, “green”, “blue”]
addStand_pie_source = ColumnDataSource(data = dict(colors = addStand_pie_colors, start_angle = starts, end_angle = ends, legend = addStand_pie_legend))
addStand_pie = figure(x_range=(-0.9, 1), y_range=(-0.6, 0.6), plot_width = 200, plot_height = 180, title=“Add Stand”)
#for i in range(len(starts)):
addStand_pie.wedge(x=-0.25 , y=0, radius=.5, start_angle=starts[i], end_angle=ends[i], color=pie_colors[i], legend=addStand_pie_legend[i])
addStand_pie.wedge(x=-0.25 , y=0, radius=.5, start_angle=‘start_angle’, end_angle=‘end_angle’, color=‘colors’, legend=‘legend’, source = addStand_pie_source)
addStand_pie.title.align = ‘center’
addStand_pie.xaxis.visible = None
addStand_pie.yaxis.visible = None
addStand_pie.toolbar.logo = None
addStand_pie.toolbar_location = None
addStand_pie.min_border_left = 0
addStand_pie.min_border_right = 0
addStand_pie.min_border_top = 0
addStand_pie.min_border_bottom = 0
addStand_pie.legend.location = “center_right”
addStand_pie.legend.label_text_font_size = ‘6pt’
addStand_pie.legend.glyph_height = 10
addStand_pie.legend.glyph_width = 10
addStand_pie.legend.background_fill_alpha = 0
addStand_pie.legend.border_line_alpha = 0
addStand_pie.legend.padding = 0
addStand_pie.legend.spacing = 1
pie takeWeight
connection_phase_query = ‘{} in [“S2B”,]’.format(connection_phase_str)
type_query = ‘{} in [“TakeWeight”,]’.format(type_str)
status_query = ‘{} in [“Canceled”, “Completed”, “Failed”]’.format(status_str)
takeWeight_table = selected_rig_table.query(connection_phase_query).query(type_query).query(status_query)
takeWeight_pie_dict = takeWeight_table.groupby(status_str).size().to_dict()
takeWeight_pie_legend = list(takeWeight_pie_dict.keys())
starts, ends = calculate_percentage(takeWeight_pie_dict)
takeWeight_pie_colors = [“red”, “green”, “blue”]
takeWeight_pie_source = ColumnDataSource(data = dict(colors = takeWeight_pie_colors, start_angle = starts, end_angle = ends, legend = takeWeight_pie_legend))
takeWeight_pie = figure(x_range=(-0.9, 1), y_range=(-0.6, 0.6), plot_width = 200, plot_height = 180, title=“Take Weight”)
#for i in range(len(starts)):
takeWeight_pie.wedge(x=-0.25 , y=0, radius=.5, start_angle=starts[i], end_angle=ends[i], color=pie_colors[i], legend=takeWeight_pie_legend[i])
takeWeight_pie.wedge(x=-0.25 , y=0, radius=.5, start_angle=‘start_angle’, end_angle=‘end_angle’, color=‘colors’, legend=‘legend’, source = takeWeight_pie_source)
takeWeight_pie.title.align = ‘center’
takeWeight_pie.xaxis.visible = None
takeWeight_pie.yaxis.visible = None
takeWeight_pie.toolbar.logo = None
takeWeight_pie.toolbar_location = None
takeWeight_pie.min_border_left = 0
takeWeight_pie.min_border_right = 0
takeWeight_pie.min_border_top = 0
takeWeight_pie.min_border_bottom = 0
takeWeight_pie.legend.location = “center_right”
takeWeight_pie.legend.label_text_font_size = ‘6pt’
takeWeight_pie.legend.glyph_height = 10
takeWeight_pie.legend.glyph_width = 10
takeWeight_pie.legend.background_fill_alpha = 0
takeWeight_pie.legend.border_line_alpha = 0
takeWeight_pie.legend.padding = 0
takeWeight_pie.legend.spacing = 1
pie flowSetpoint
connection_phase_query = ‘{} in [“S2B”,]’.format(connection_phase_str)
type_query = ‘{} in [“FlowSetpoint”,]’.format(type_str)
status_query = ‘{} in [“Canceled”, “Failed”]’.format(status_str)
flowSetpoint_table = selected_rig_table.query(connection_phase_query).query(type_query).query(status_query)
flowSetpoint_pie_dict = flowSetpoint_table.groupby(status_str).size().to_dict()
flowSetpoint_pie_legend = list(flowSetpoint_pie_dict.keys())
starts, ends = calculate_percentage(flowSetpoint_pie_dict)
flowSetpoint_pie_colors = [“red”, “green”]
flowSetpoint_pie_source = ColumnDataSource(data = dict(colors = flowSetpoint_pie_colors, start_angle = starts, end_angle = ends, legend = flowSetpoint_pie_legend))
flowSetpoint_pie = figure(x_range=(-0.9, 1), y_range=(-0.6, 0.6), plot_width = 200, plot_height = 180, title=“Flow Setpoint”)
#for i in range(len(starts)):
flowSetpoint_pie.wedge(x=-0.25 , y=0, radius=.5, start_angle=starts[i], end_angle=ends[i], color=pie_colors[i], legend=flowSetpoint_pie_legend[i])
flowSetpoint_pie.wedge(x=-0.25 , y=0, radius=.5, start_angle=‘start_angle’, end_angle=‘end_angle’, color=‘colors’, legend=‘legend’, source = flowSetpoint_pie_source)
flowSetpoint_pie.title.align = ‘center’
flowSetpoint_pie.xaxis.visible = None
flowSetpoint_pie.yaxis.visible = None
flowSetpoint_pie.toolbar.logo = None
flowSetpoint_pie.toolbar_location = None
flowSetpoint_pie.min_border_left = 0
flowSetpoint_pie.min_border_right = 0
flowSetpoint_pie.min_border_top = 0
flowSetpoint_pie.min_border_bottom = 0
flowSetpoint_pie.legend.location = “center_right”
flowSetpoint_pie.legend.label_text_font_size = ‘6pt’
flowSetpoint_pie.legend.glyph_height = 10
flowSetpoint_pie.legend.glyph_width = 10
flowSetpoint_pie.legend.background_fill_alpha = 0
flowSetpoint_pie.legend.border_line_alpha = 0
flowSetpoint_pie.legend.padding = 0
flowSetpoint_pie.legend.spacing = 1
#########################
pie rotateDrill
connection_phase_query = ‘{} in [“S2B”,]’.format(connection_phase_str)
type_query = ‘{} in [“RotateDrill”,]’.format(type_str)
status_query = ‘{} in [“Canceled”, “Completed”, “Failed”]’.format(status_str)
rotateDrill_table = selected_rig_table.query(connection_phase_query).query(type_query).query(status_query)
rotateDrill_pie_dict = rotateDrill_table.groupby(status_str).size().to_dict()
rotateDrill_pie_legend = list(rotateDrill_pie_dict.keys())
starts, ends = calculate_percentage(rotateDrill_pie_dict)
rotateDrill_pie_colors = [“red”, “green”, “blue”]
rotateDrill_pie_source = ColumnDataSource(data = dict(colors = rotateDrill_pie_colors, start_angle = starts, end_angle = ends, legend = rotateDrill_pie_legend))
rotateDrill_pie = figure(x_range=(-0.9, 1), y_range=(-0.6, 0.6), plot_width = 200, plot_height = 180, title=“Rotate Drill”)
#for i in range(len(starts)):
rotateDrill_pie.wedge(x=-0.25 , y=0, radius=.5, start_angle=starts[i], end_angle=ends[i], color=pie_colors[i], legend=rotateDrill_pie_legend[i])
rotateDrill_pie.wedge(x=-0.25 , y=0, radius=.5, start_angle=‘start_angle’, end_angle=‘end_angle’, color=‘colors’, legend=‘legend’, source = rotateDrill_pie_source)
rotateDrill_pie.title.align = ‘center’
rotateDrill_pie.xaxis.visible = None
rotateDrill_pie.yaxis.visible = None
rotateDrill_pie.toolbar.logo = None
rotateDrill_pie.toolbar_location = None
rotateDrill_pie.min_border_left = 0
rotateDrill_pie.min_border_right = 0
rotateDrill_pie.min_border_top = 0
rotateDrill_pie.min_border_bottom = 0
rotateDrill_pie.legend.location = “center_right”
rotateDrill_pie.legend.label_text_font_size = ‘6pt’
rotateDrill_pie.legend.glyph_height = 10
rotateDrill_pie.legend.glyph_width = 10
rotateDrill_pie.legend.background_fill_alpha = 0
rotateDrill_pie.legend.border_line_alpha = 0
rotateDrill_pie.legend.padding = 0
rotateDrill_pie.legend.spacing = 1
#########################
pie tagBottom
connection_phase_query = ‘{} in [“S2B”,]’.format(connection_phase_str)
type_query = ‘{} in [“TagBottom”,]’.format(type_str)
status_query = ‘{} in [“Canceled”, “Completed”, “Failed”]’.format(status_str)
tagBottom_table = selected_rig_table.query(connection_phase_query).query(type_query).query(status_query)
tagBottom_pie_dict = tagBottom_table.groupby(status_str).size().to_dict()
tagBottom_pie_legend = list(tagBottom_pie_dict.keys())
starts, ends = calculate_percentage(tagBottom_pie_dict)
tagBottom_pie_colors = [“red”, “green”, “blue”]
tagBottom_pie_source = ColumnDataSource(data = dict(colors = tagBottom_pie_colors, start_angle = starts, end_angle = ends, legend = tagBottom_pie_legend))
tagBottom_pie = figure(x_range=(-0.9, 1), y_range=(-0.6, 0.6), plot_width = 200, plot_height = 180, title=“Tag Bottom”)
#for i in range(len(starts)):
tagBottom_pie.wedge(x=-0.25 , y=0, radius=.5, start_angle=starts[i], end_angle=ends[i], color=pie_colors[i], legend=tagBottom_pie_legend[i])
tagBottom_pie.wedge(x=-0.25 , y=0, radius=.5, start_angle=‘start_angle’, end_angle=‘end_angle’, color=‘colors’, legend=‘legend’, source = tagBottom_pie_source)
tagBottom_pie.title.align = ‘center’
tagBottom_pie.xaxis.visible = None
tagBottom_pie.yaxis.visible = None
tagBottom_pie.toolbar.logo = None
tagBottom_pie.toolbar_location = None
tagBottom_pie.min_border_left = 0
tagBottom_pie.min_border_right = 0
tagBottom_pie.min_border_top = 0
tagBottom_pie.min_border_bottom = 0
tagBottom_pie.legend.location = “center_right”
tagBottom_pie.legend.label_text_font_size = ‘6pt’
tagBottom_pie.legend.glyph_height = 10
tagBottom_pie.legend.glyph_width = 10
tagBottom_pie.legend.background_fill_alpha = 0
tagBottom_pie.legend.border_line_alpha = 0
tagBottom_pie.legend.padding = 0
tagBottom_pie.legend.spacing = 1
novos_connection_s2b_layout = gridplot([[addStand_pie, takeWeight_pie],
[flowSetpoint_pie, rotateDrill_pie],
[tagBottom_pie,]],
plot_width=200, plot_height=200,
title=“haha”, toolbar_location = None)
m_b2s_title = Div(text=‘Bottom to Slips’, width = 400, height=15, style={‘font-size’: ‘100%’, “text-align”:“center”, “font-weight”: “bold”})
novos_b2s_column = column(children=[m_b2s_title, novos_connection_b2s_layout])
m_s2b_title = Div(text=‘Slips to Bottom’, width = 400, height=15, style={‘font-size’: ‘100%’, “text-align”:“center”, “font-weight”: “bold”})
novos_s2b_column = column(children=[m_s2b_title, novos_connection_s2b_layout])
line_figure = figure(x_range=(0, 5), y_range=(0, 600), plot_width = 30, plot_height = 600)
line_figure.line(x=[1, 1], y= [0, 600], line_width = 3, line_color=‘black’)
line_figure.xaxis.visible = None
line_figure.yaxis.visible = None
line_figure.toolbar.logo = None
line_figure.toolbar_location = None
line_figure.toolbar.active_drag = None
line_figure.min_border_left = 0
line_figure.min_border_right = 0
line_figure.min_border_top = 0
line_figure.min_border_bottom = 0
summary_layout = layout(row(well_connection_chart, novos_b2s_column, line_figure, novos_s2b_column))
def get_data(all_connection_dict, rig = -1, job = -1):
global hole_depth_str
global pre_slip_time_str
global post_slip_time_str
global survey_time_str
global backream_time_str
global slip_to_slip_str
all_connection_table = {}
all_connection_table = pd.DataFrame.from_dict(all_connection_dict)
depth_list =
b2s_list =
s2s_list =
s2b_list =
survey_list =
ream_list =
b2s_s2s_list =
b2s_s2s_s2b_list =
b2s_s2s_s2b_survey_list =
b2s_s2s_s2b__survey_ream_list =
if(( rig == -1) or (job == -1)):
depth_list = list(map(float, all_connection_table[hole_depth_str]))
depth_list.sort(key=float)
b2s_list = list(map(float, all_connection_table[pre_slip_time_str]))
s2s_list = list(map(float, all_connection_table[slip_to_slip_str]))
s2b_list = list(map(float, all_connection_table[post_slip_time_str]))
survey_list = list(map(float, all_connection_table[survey_time_str]))
ream_list = list(map(float, all_connection_table[backream_time_str]))
else:
global rig_id_str
global job_id_str
rig_target =
rig_target.append(int(rig))
rig_target.append(‘’)
rigs_query = “{} in @rig_target”.format(rig_id_str)
selected_rig_table = all_connection_table.query(rigs_query)
job_target =
job_target.append(int(job))
job_target.append(‘’)
jobs_query = “{} in @job_target”.format(job_id_str)
selected_job_table = selected_rig_table.query(jobs_query)
depth_list = list(map(float, selected_job_table[hole_depth_str]))
depth_list.sort(key=float)
b2s_list = list(map(float, selected_job_table[pre_slip_time_str]))
s2s_list = list(map(float, selected_job_table[slip_to_slip_str]))
s2b_list = list(map(float, selected_job_table[post_slip_time_str]))
survey_list = list(map(float, all_connection_table[survey_time_str]))
ream_list = list(map(float, all_connection_table[backream_time_str]))
b2s_s2s_list = list(map(add, b2s_list, s2s_list))
b2s_s2s_s2b_list = list(map(add, b2s_s2s_list, s2b_list))
b2s_s2s_s2b_survey_list = list(map(add, b2s_s2s_s2b_list, survey_list))
b2s_s2s_s2b__survey_ream_list = list(map(add, b2s_s2s_s2b_survey_list, ream_list))
could be a function
rig_job_dict = {}
rig_job_dict[‘VBarTop’] =
rig_job_dict[‘VBarBottom’] =
rig_job_dict[‘VBarColors’] =
rig_job_dict[‘VBarType’] =
rig_job_dict[‘HoleDepth’] = depth_list + depth_list + depth_list + depth_list + depth_list
rig_job_dict[‘VBarTop’] = b2s_list + b2s_s2s_list + b2s_s2s_s2b_list + b2s_s2s_s2b_survey_list + b2s_s2s_s2b__survey_ream_list
rig_job_dict[‘VBarBottom’] = [ 0 for item in b2s_list] + b2s_list + b2s_s2s_list + b2s_s2s_s2b_list + b2s_s2s_s2b_survey_list
rig_job_dict[‘VBarColors’] = [ “blue” for item in b2s_list] \
-
[ “red” for item in b2s_s2s_list] \
-
[ “yellow” for item in b2s_s2s_s2b_list] \
-
[ “green” for item in b2s_s2s_s2b_survey_list]\
-
[ “orange” for item in b2s_s2s_s2b__survey_ream_list]
rig_job_dict[‘VBarType’] = [‘B2S’ for item in b2s_s2s_s2b_list] \
-
[‘S2S’ for item in b2s_s2s_s2b_list] \
-
[‘S2B’ for item in b2s_s2s_s2b_list] \
-
[‘Survey’ for item in b2s_s2s_s2b_list] \
-
[‘Ream’ for item in b2s_s2s_s2b_list]
return rig_job_dict, depth_list
def update(selected = None):
rig_job_dict = {}
depth_list =
if selected != None:
rig_job_dict, depth_list = get_data(all_connection_dict)
else:
rig, job = rigs_combx.value, jobs_combx.value
rig_job_dict, depth_list = get_data(all_connection_dict, rig, job)
return rig_job_dict, depth_list
#replace 0 with the previous depth value
def remove_empty_depth(in_dict):
out_dict = {}
out_dict.update([(key, in_dict[key]) for key in in_dict.keys() if ((in_dict[depth_ft_str] != ‘’))])
return out_dict
novos_connection_dict_without_emptydepth = remove_empty_depth(novos_connection_dict)
novos_source = ColumnDataSource(data=novos_connection_dict_without_emptydepth)
mainplot_data_all, depth_list_all = update(“all”)
depth_list_all = [str(x) for x in depth_list_all]
main_plot = figure(output_backend=“webgl”, x_range=FactorRange(), y_range = (0, 40), plot_height=150, tools = “tap, pan, box_zoom, box_select, wheel_zoom, reset”, sizing_mode=‘scale_width’, title=“Overall Connection Times”)
main_plot.title.align = ‘center’
main_plot.legend.location = “top_left”
main_plot.legend.click_policy=“hide”
main_plot.x_range.factors =
main_plot.x_range.factors = depth_list_all
mainplot_data_all[‘HoleDepth’] = [str(x) for x in mainplot_data_all[‘HoleDepth’]]
mainplot_source = ColumnDataSource(data=dict(HoleDepth = mainplot_data_all[‘HoleDepth’],
VBarTop = mainplot_data_all[‘VBarTop’],
VBarBottom = mainplot_data_all[‘VBarBottom’],
VBarColors = mainplot_data_all[‘VBarColors’],
VBarType = mainplot_data_all[‘VBarType’]))
main_plot.vbar(x=‘HoleDepth’, width=0.1, bottom=‘VBarBottom’, top=‘VBarTop’, color=‘VBarColors’, source=mainplot_source, legend=‘VBarType’)
#20180622 start
def merge(a, b, path=None):
“merges b into a”
if path is None: path =
for key in b:
if key in a:
if isinstance(a[key], dict) and isinstance(b[key], dict):
merge(a[key], b[key], path + [str(key)])
elif a[key] == b[key]:
pass # same leaf value
else:
raise Exception(‘Conflict at %s’ % ‘.’.join(path + [str(key)]))
else:
a[key] = b[key]
return a
def update_checkBx_groups_dict(checkbox_group_1_selections = ,
checkbox_group_2_selections = ):
#1. get jobs table
all_connection_table = {}
all_connection_table = pd.DataFrame.from_dict(all_connection_dict)
global selected_rig
global selected_job
rig = selected_rig
job = selected_job
global rig_id_str
global job_id_str
rig_target =
rig_target.append(int(rig))
rig_target.append(‘’)
rigs_query = “{} in @rig_target”.format(rig_id_str)
selected_rig_table = all_connection_table.query(rigs_query)
job_target =
job_target.append(int(job))
job_target.append(‘’)
jobs_query = “{} in @job_target”.format(job_id_str)
selected_job_table = selected_rig_table.query(jobs_query)
#2. generate a table based on selections from 3 groups
global well_selection_str
main_plot_group1_dict = {}
group_1_table = selected_job_table
if not checkbox_group_1_selections:
group_1_query = ‘{} in [“Build”, “Vertical”, “Lateral”]’.format(well_selection_str)
main_plot_group1_dict = group_1_table.query(group_1_query).to_dict(‘dict’)
else:
for selected in checkbox_group_1_selections:
if selected == ‘Build’:
build_dict={}
build_query = ‘{} in [“Build”,]’.format(well_selection_str)
build_dict = group_1_table.query(build_query).to_dict(‘dict’)
#to merge multiple dicts with same key
if not bool(main_plot_group1_dict):
main_plot_group1_dict = build_dict
else:
#main_plot_group1_dict = {i:list(j) for i in build_dict.keys() for j in zip(build_dict.values(),main_plot_group1_dict.values())}
main_plot_group1_dict = merge(main_plot_group1_dict, build_dict)
#main_plot_group1_dict = {i:list(j) for i in build_dict.keys() for j in zip(build_dict.values(),main_plot_group1_dict.values())}
elif selected == ‘Vertical’:
vertical_dict={}
vertical_query = ‘{} in [“Vertical”,]’.format(well_selection_str)
vertical_dict = group_1_table.query(vertical_query).to_dict(‘dict’)
if not bool(main_plot_group1_dict):
main_plot_group1_dict = vertical_dict
else:
#main_plot_group1_dict = {i:list(j) for i in vertical_dict.keys() for j in zip(vertical_dict.values(),main_plot_group1_dict.values())}
main_plot_group1_dict = merge(main_plot_group1_dict, vertical_dict)
elif selected == “Lateral”:
lateral_dict={}
lateral_query = ‘{} in [“Lateral”,]’.format(well_selection_str)
lateral_dict = group_1_table.query(lateral_query).to_dict(‘dict’)
if not bool(main_plot_group1_dict):
main_plot_group1_dict = lateral_dict
else:
#main_plot_group1_dict = {i:list(j) for i in lateral_dict.keys() for j in zip(lateral_dict.values(),main_plot_group1_dict.values())}
main_plot_group1_dict = merge(main_plot_group1_dict, lateral_dict)
global connection_type_str
main_plot_group2_dict = {}
group_2_table = pd.DataFrame.from_dict(main_plot_group1_dict)
if not checkbox_group_2_selections:
group_2_query = ‘{} in [“Driller”, “Hybrid”, “Novos”]’.format(connection_type_str)
main_plot_group2_dict = group_2_table.query(group_2_query).to_dict(‘dict’)
else:
for selected in checkbox_group_2_selections:
if selected == ‘Driller’:
driller_dict = {}
driller_query = ‘{} in [“Driller”,]’.format(connection_type_str)
driller_dict = group_2_table.query(driller_query).to_dict(‘dict’)
if not bool(main_plot_group2_dict):
main_plot_group2_dict = driller_dict
else:
main_plot_group2_dict = merge(main_plot_group2_dict, driller_dict)
elif selected == ‘Hybrid’:
hybrid_dict = {}
hybrid_query = ‘{} in [“Hybrid”,]’.format(connection_type_str)
hybrid_dict = group_2_table.query(hybrid_query).to_dict(‘dict’)
if not bool(main_plot_group2_dict):
main_plot_group2_dict = hybrid_dict
else:
main_plot_group2_dict = merge(main_plot_group2_dict, hybrid_dict)
elif selected == “Novos”:
novos_dict = {}
novos_query = ‘{} in [“Novos”,]’.format(connection_type_str)
novos_dict = group_2_table.query(novos_query).to_dict(‘dict’)
if not bool(main_plot_group2_dict):
main_plot_group2_dict = novos_dict
else:
main_plot_group2_dict = merge(main_plot_group2_dict, novos_dict)
return main_plot_group2_dict
def update_main_plot_dict(in_main_plot_dict, checkbox_group_3_selections = ):
“update main dict”
wellSel_connType_groups_table = pd.DataFrame.from_dict(in_main_plot_dict)
global hole_depth_str
global pre_slip_time_str
global post_slip_time_str
global survey_time_str
global backream_time_str
global slip_to_slip_str
depth_list =
b2s_list =
s2s_list =
s2b_list =
survey_list =
ream_list =
b2s_s2s_list =
b2s_s2s_s2b_list =
b2s_s2s_s2b_survey_list =
b2s_s2s_s2b__survey_ream_list =
depth_list = list(map(float, wellSel_connType_groups_table[hole_depth_str]))
b2s_list = list(map(float, wellSel_connType_groups_table[pre_slip_time_str]))
s2s_list = list(map(float, wellSel_connType_groups_table[slip_to_slip_str]))
s2b_list = list(map(float, wellSel_connType_groups_table[post_slip_time_str]))
survey_list = list(map(float, wellSel_connType_groups_table[survey_time_str]))
ream_list = list(map(float, wellSel_connType_groups_table[backream_time_str]))
could be a function
main_plot_dict = {}
main_plot_dict[‘VBarTop’] =
main_plot_dict[‘VBarBottom’] =
main_plot_dict[‘VBarColors’] =
main_plot_dict[‘VBarType’] =
main_plot_dict[‘HoleDepth’] =
main_plot_list =
main_plot_depth_list =
main_plot_top_list =
main_plot_bottom_list =
main_plot_color_list =
main_plot_type_list =
if not checkbox_group_3_selections:
b2s_s2s_list = list(map(add, b2s_list, s2s_list))
b2s_s2s_s2b_list = list(map(add, b2s_s2s_list, s2b_list))
b2s_s2s_s2b_survey_list = list(map(add, b2s_s2s_s2b_list, survey_list))
b2s_s2s_s2b__survey_ream_list = list(map(add, b2s_s2s_s2b_survey_list, ream_list))
main_plot_depth_list = depth_list + depth_list + depth_list + depth_list + depth_list
main_plot_top_list = b2s_list + b2s_s2s_list + b2s_s2s_s2b_list + b2s_s2s_s2b_survey_list + b2s_s2s_s2b__survey_ream_list
main_plot_bottom_list = [ 0 for item in b2s_list] + b2s_list + b2s_s2s_list + b2s_s2s_s2b_list + b2s_s2s_s2b_survey_list
main_plot_color_list = [ “blue” for item in b2s_list] \
-
[ “red” for item in b2s_s2s_list] \
-
[ “yellow” for item in b2s_s2s_s2b_list] \
-
[ “green” for item in b2s_s2s_s2b_survey_list]\
-
[ “orange” for item in b2s_s2s_s2b__survey_ream_list]
main_plot_type_list = [‘B2S’ for item in b2s_list] \
-
[‘S2S’ for item in s2s_list] \
-
[‘S2B’ for item in s2b_list] \
-
[‘Survey’ for item in survey_list] \
-
[‘Ream’ for item in ream_list]
else:
for selected in checkbox_group_3_selections:
if selected == ‘B2S’:
main_plot_depth_list = main_plot_depth_list + depth_list
main_plot_list = main_plot_list + b2s_list
main_plot_type_list = main_plot_type_list + [‘B2S’ for item in b2s_list]
main_plot_color_list = main_plot_color_list + [ “blue” for item in b2s_list]
elif selected == ‘S2S’:
main_plot_depth_list = main_plot_depth_list + depth_list
main_plot_list = main_plot_list + s2s_list
main_plot_type_list = main_plot_type_list + [‘S2S’ for item in s2s_list]
main_plot_color_list = main_plot_color_list + [ “red” for item in s2s_list]
elif selected == “S2B”:
main_plot_depth_list = main_plot_depth_list + depth_list
main_plot_list = main_plot_list + s2b_list
main_plot_type_list = main_plot_type_list + [‘S2B’ for item in s2b_list]
main_plot_color_list = main_plot_color_list + [ “yellow” for item in s2b_list]
elif selected == “Survey”:
main_plot_depth_list = main_plot_depth_list + depth_list
main_plot_list = main_plot_list + survey_list
main_plot_type_list = main_plot_type_list + [‘Survey’ for item in survey_list]
main_plot_color_list = main_plot_color_list + [ “green” for item in survey_list]
elif selected == “BackReam”:
main_plot_depth_list = main_plot_depth_list + depth_list
main_plot_list = main_plot_list + ream_list
main_plot_type_list = main_plot_type_list + [‘BackReam’ for item in ream_list]
main_plot_color_list = main_plot_color_list + [ “orange” for item in ream_list]
generate top&bottom values
section_length = len(depth_list)
main_plot_top_list = main_plot_list
connectionPhase_selections = int(len(main_plot_list) / len(depth_list))
for i in range(0, connectionPhase_selections):
if i > 0 :
prev_section_head = (i - 1) * section_length
current_section_head = i * section_length
temp_list = [(main_plot_top_list[prev_section_head + k] + main_plot_list[current_section_head + k]) for k in range(0, section_length)]
main_plot_top_list = main_plot_top_list + temp_list
else:
main_plot_top_list = [main_plot_list[k] for k in range(0, section_length)]
bottom_list_slice_upbound = (connectionPhase_selections - 1) * section_length
main_plot_bottom_list = [ 0 for k in range(0, section_length)]
if (connectionPhase_selections - 1) > 0:
main_plot_bottom_list = main_plot_bottom_list + main_plot_top_list[:bottom_list_slice_upbound]
else:
main_plot_bottom_list = main_plot_bottom_list
print(“check the length of slice”)
print(len(main_plot_top_list))
print(len(main_plot_bottom_list))
main_plot_dict[‘HoleDepth’] = main_plot_depth_list
main_plot_dict[‘VBarTop’] = main_plot_top_list
main_plot_dict[‘VBarBottom’] = main_plot_bottom_list
main_plot_dict[‘VBarColors’] = main_plot_color_list
main_plot_dict[‘VBarType’] = main_plot_type_list
return main_plot_dict, depth_list
def update_main_plot_source(mainplot_data, depth_list):
def update_holeDepth_list(mainplot_data, mainplot_data_all ):
mainplot_data_length = len(mainplot_data[‘HoleDepth’])
mainplot_data_all_length = len(mainplot_data_all[‘HoleDepth’])
mainplot_data_holeDepth_list =
i = 0
for item in mainplot_data_all[‘HoleDepth’]:
if item in depth_list:
if i >= mainplot_data_length:
mainplot_data_holeDepth_list.append(‘-1’)
else:
mainplot_data_holeDepth_list.append(item)
i = i + 1
else:
mainplot_data_holeDepth_list.append(‘-1’)
return mainplot_data_holeDepth_list
#mainplot_source.data[‘HoleDepth’] = [item if item in depth_list else ‘-1’ for item in mainplot_data_all[‘HoleDepth’]]
mainplot_source.data[‘HoleDepth’] = update_holeDepth_list(mainplot_data, mainplot_data_all)
mainplot_source.data[‘VBarTop’] = updateSourceData(‘VBarTop’, mainplot_data, mainplot_source.data)
mainplot_source.data[‘VBarBottom’] = updateSourceData(‘VBarBottom’, mainplot_data, mainplot_source.data)
mainplot_source.data[‘VBarColors’] = updateSourceData(‘VBarColors’, mainplot_data, mainplot_source.data)
vBarType_list = updateSourceData(‘VBarType’, mainplot_data, mainplot_source.data)
mainplot_source.data[‘VBarType’] = vBarType_list
def update_main_plot(main_plot, from_comboBx_group = False):
main_plot_dict = {}
depth_list =
checkbox_group_1_selections =
checkbox_group_2_selections =
checkbox_group_3_selections =
if from_comboBx_group == True:
checkbox_group_1_selections = [checkbox_group_1.labels[i] for i in
checkbox_group_1.active]
checkbox_group_2_selections = [checkbox_group_2.labels[i] for i in
checkbox_group_2.active]
checkbox_group_3_selections = [checkbox_group_3.labels[i] for i in
checkbox_group_3.active]
main_plot_dict = update_checkBx_groups_dict(checkbox_group_1_selections,
checkbox_group_2_selections)
main_plot_dict, depth_list = update_main_plot_dict(main_plot_dict, checkbox_group_3_selections)
else:
main_plot_dict = update_checkBx_groups_dict()
main_plot_dict, depth_list = update_main_plot_dict(main_plot_dict)
depth_list = [str(x) for x in depth_list]
update_main_plot_source(main_plot_dict, depth_list)
main_plot.x_range.factors =
main_plot.x_range.factors = depth_list
def checkbox_callback_1(attr, old, new):
update_main_plot(main_plot, True)
Update the source used in the quad glpyhs
#src.data.update(new_src.data)
def checkbox_callback_2(attr, old, new):
update_main_plot(main_plot, True)
Update the source used in the quad glpyhs
#src.data.update(new_src.data)
def checkbox_callback_3(attr, old, new):
update_main_plot(main_plot, True)
Update the source used in the quad glpyhs
#src.data.update(new_src.data)
checkbox_group_1.on_change(‘active’, checkbox_callback_1)
checkbox_group_2.on_change(‘active’, checkbox_callback_2)
checkbox_group_3.on_change(‘active’, checkbox_callback_3)
#20180622 End
update_main_plot(main_plot)
#main_plot.legend.legend_spacing = 10
#main_plot.legend.legend_padding = 50
main_plot.toolbar.logo = None
taptool = main_plot.select(type=TapTool)
#subplot
subplot_dict = {}
subplot_dict[‘B2SText’] = [‘Cleanhole - Active’, ‘Cleanhole - Completed’, ‘Setboxheight - Active’, ‘Setboxheight - Completed’, ‘Setweight - Active’, ‘Setweight - Completed’, ‘Offbottom-Active’, ‘Unweightbit - Active’, ‘Unweightbit - Completed’, ‘Clearbit - Active’, ‘Clearbit - Completed’, ‘Offbottom - Completed’]
subplot_dict[‘text_x’] = [4, 12, 20, 28, 36, 44, 4, 12, 20, 28, 36, 44]
subplot_dict[‘B2SColors’] = [‘white’, ‘white’, ‘white’, ‘white’, ‘white’, ‘white’, ‘white’, ‘white’, ‘white’, ‘white’, ‘white’, ‘white’]
subplot_dict[‘B2STextColors’] = [‘black’, ‘black’, ‘black’, ‘black’, ‘black’, ‘black’, ‘black’, ‘black’, ‘black’, ‘black’, ‘black’, ‘black’]
subplot_dict[‘B2SHideColors’] = [‘white’, ‘white’, ‘white’, ‘white’, ‘white’, ‘white’, ‘white’, ‘white’, ‘white’, ‘white’, ‘white’, ‘white’]
subplot_dict[‘subplot_x’] = [7, 15, 23, 31, 39, 47,7, 15, 23, 31, 39, 47]
subplot_dict[‘subplot_y’] = [20, 20, 20, 20, 20, 20, 25, 25, 25, 25, 25, 25]
subplot_dict[‘B2SArrowColors’] = [‘#ebebe0’, ‘#ebebe0’, ‘#ebebe0’, ‘#ebebe0’, ‘#ebebe0’, ‘#ebebe0’, ‘#ebebe0’, ‘#ebebe0’, ‘#ebebe0’, ‘#ebebe0’, ‘#ebebe0’, ‘#ebebe0’]
subplot_dict[‘ArrowStartX’] = [10, 18, 26, 34, 42, 42, 10, 18, 26, 34, 42, 42]
subplot_dict[‘ArrowEndX’] = [12, 20, 28, 36, 44, 44, 12, 20, 28, 36, 44, 44]
subplot_dict[‘ArrowY’] = [20, 20, 20, 20, 20, 20, 25, 25, 25, 25, 25, 25]
subplot_dict[‘arrow_end_y’] = [20, 20, 20, 20, 20, 20, 25, 25, 25, 25, 25, 25]
subplot_dict[‘Text’] = [‘’, ‘’, ‘’, ‘’,‘’, ‘’, ‘’, ‘’,‘’, ‘’, ‘’, ‘’]
subplot_source = ColumnDataSource(data=subplot_dict)
subplot.rect(x=‘subplot_x’, y=‘subplot_y’, width=subplot_weight, height=subplot_height, color=“B2SColors”,
width_units=“screen”, height_units=“screen”, source=subplot_source)
b2s_text = Text(x=‘text_x’, y=‘subplot_y’, text_color=“B2STextColors”, text=“Text”, )
subplot.add_glyph(subplot_source, b2s_text)
‘’’
#1
arrow_lines_dict = {}
arrow_lines_dict[‘x’] = [11.5, 11.8, 11.5, 11.8, 10.2]
arrow_lines_dict[‘y’] = [24.8, 25, 25.2, 25, 25]
arrow_lines_source_1 = ColumnDataSource(data=arrow_lines_dict)
arrow_lines = Line(x=“x”, y=“y”, line_color=“black”, line_width=1, line_alpha=0.6)
subplot.add_glyph(arrow_lines_source_1, arrow_lines)
#2
arrow_lines_dict = {}
arrow_lines_dict[‘x’] = [19.5, 19.8, 19.5, 19.8, 18]
arrow_lines_dict[‘y’] = [24.8, 25, 25.2, 25, 25]
arrow_lines_source_2 = ColumnDataSource(data=arrow_lines_dict)
arrow_lines = Line(x=“x”, y=“y”, line_color=“black”, line_width=1, line_alpha=0.6)
subplot.add_glyph(arrow_lines_source_2, arrow_lines)
#3
arrow_lines_dict = {}
arrow_lines_dict[‘x’] = [27.5, 27.8, 27.5, 27.8, 20.2]
arrow_lines_dict[‘y’] = [24.8, 25, 25.2, 25, 25]
arrow_lines_source_3 = ColumnDataSource(data=arrow_lines_dict)
arrow_lines = Line(x=“x”, y=“y”, line_color=“black”, line_width=1, line_alpha=0.6)
subplot.add_glyph(arrow_lines_source_3, arrow_lines)
#4
arrow_lines_dict = {}
arrow_lines_dict[‘x’] = [35.5, 35.8, 35.5, 35.8, 28.2]
arrow_lines_dict[‘y’] = [24.8, 25, 25.2, 25, 25]
arrow_lines_source_4 = ColumnDataSource(data=arrow_lines_dict)
arrow_lines = Line(x=“x”, y=“y”, line_color=“black”, line_width=1, line_alpha=0.6)
subplot.add_glyph(arrow_lines_source_4, arrow_lines)
#5
arrow_lines_dict = {}
arrow_lines_dict[‘x’] = [44.5, 44.8, 44.5, 44.8, 36.2]
arrow_lines_dict[‘y’] = [24.8, 25, 25.2, 25, 25]
arrow_lines_source_5 = ColumnDataSource(data=arrow_lines_dict)
arrow_lines = Line(x=“x”, y=“y”, line_color=“black”, line_width=1, line_alpha=0.6)
subplot.add_glyph(arrow_lines_source_5, arrow_lines)
#6
arrow_lines_dict = {}
arrow_lines_dict[‘x’] = [11.5, 11.8, 11.5, 11.8, 10.2]
arrow_lines_dict[‘y’] = [19.8, 20, 20.2, 20, 20]
arrow_lines_source_6 = ColumnDataSource(data=arrow_lines_dict)
arrow_lines = Line(x=“x”, y=“y”, line_color=“black”, line_width=1, line_alpha=0.6)
subplot.add_glyph(arrow_lines_source_6, arrow_lines)
#7
arrow_lines_dict = {}
arrow_lines_dict[‘x’] = [19.5, 19.8, 19.5, 19.8, 12.2]
arrow_lines_dict[‘y’] = [19.8, 20, 20.2, 20, 20]
arrow_lines_source_7 = ColumnDataSource(data=arrow_lines_dict)
arrow_lines = Line(x=“x”, y=“y”, line_color=“black”, line_width=1, line_alpha=0.6)
subplot.add_glyph(arrow_lines_source_7, arrow_lines)
#8
arrow_lines_dict = {}
arrow_lines_dict[‘x’] = [27.5, 27.8, 27.5, 27.8, 20.2]
arrow_lines_dict[‘y’] = [19.8, 20, 20.2, 20, 20]
arrow_lines_source_8 = ColumnDataSource(data=arrow_lines_dict)
arrow_lines = Line(x=“x”, y=“y”, line_color=“black”, line_width=1, line_alpha=0.6)
subplot.add_glyph(arrow_lines_source_8, arrow_lines)
#9
arrow_lines_dict = {}
arrow_lines_dict[‘x’] = [35.5, 35.8, 35.5, 35.8, 28.2]
arrow_lines_dict[‘y’] = [19.8, 20, 20.2, 20, 20]
arrow_lines_source_9 = ColumnDataSource(data=arrow_lines_dict)
arrow_lines = Line(x=“x”, y=“y”, line_color=“black”, line_width=1, line_alpha=0.6)
subplot.add_glyph(arrow_lines_source_9, arrow_lines)
#10
arrow_lines_dict = {}
arrow_lines_dict[‘x’] = [44.5, 44.8, 44.5, 44.8, 36.2]
arrow_lines_dict[‘y’] = [19.8, 20, 20.2, 20, 20]
arrow_lines_source_10 = ColumnDataSource(data=arrow_lines_dict)
arrow_lines = Line(x=“x”, y=“y”, line_color=“black”, line_width=1, line_alpha=0.6)
subplot.add_glyph(arrow_lines_source_10, arrow_lines)
‘’’
subplot.xaxis.visible = None
subplot.yaxis.visible = None
subplot.background_fill_color = “white”
m_color_white = subplot.background_fill_color
subplot.outline_line_color = None
#show or hide
code = “”"
selection = require(“core/util/selection”)
indices = selection.get_indices(allSource)
m_color = subplot.background_fill_color
subplot.background_fill_color = ‘white’
subplotSource.data['B2SColors'][0] = 'red'
subplotSource.data['B2SColors'][1] = 'red'
subplotSource.data['B2SColors'][2] = 'red'
subplotSource.data['B2SColors'][3] = 'red'
subplotSource.data['B2SColors'][4] = 'red'
subplotSource.data['B2SColors'][5] = 'red'
subplotSource.data[‘B2SColors’][6] = ‘red’
subplotSource.data['B2SColors'][7] = 'red'
subplotSource.data['B2SColors'][8] = 'red'
subplotSource.data['B2SColors'][9] = 'red'
subplotSource.data['B2SColors'][10] = 'red'
subplotSource.data['B2SColors'][11] = 'red'
for (i = 0; i < indices.length; i++)
{
ind = indices[i]
console.log(‘-------------------------- vbar index --------------------------’)
console.log(ind)
holedepth = allSource.data[‘HoleDepth’][ind]
console.log(‘-------------------------- hole depth --------------------------’)
console.log(holedepth)
vbarType = allSource.data[‘VBarType’][ind]
for(i = 0; i < novosLength; i++)
{
console.log(novosSource.data[‘edr_depth_ft’][i])
if (novosSource.data[‘edr_depth_ft’][i] == holedepth)
{
console.log(novosSource.data[‘edr_depth_ft’][i])
console.log(“------------------ if holedepth ---------------------”)
if(vbarType == ‘B2S’)
{
console.log(“------------------ B2S ---------------------”)
console.log(novosSource.data[‘connection_phase’][i])
if (novosSource.data[‘connection_phase’][i] == vbarType)
{
console.log(novosSource.data[‘type’][i])
if (novosSource.data[‘type’][i] == ‘OffBottom’)
{
console.log(novosSource.data[‘status’][i])
if (novosSource.data[‘status’][i] == ‘Active’)
{
console.log(‘--------------------------B2S 6 Active --------------------------’)
subplotSource.data[‘B2SColors’][6] = ‘green’
subplotSource.data[‘Text’][6] = ‘Offbottom-Active’
} else if (novosSource.data[‘status’][i] == ‘Completed’)
{
console.log(‘-------------------------- B2S 6 Completed--------------------------’)
subplotSource.data[‘B2SColors’][11] = ‘green’
subplotSource.data[‘Text’][11] = ‘Offbottom-Completed’
} else
{
if (subplotSource.data[‘B2SColors’][6] != ‘green’){
subplotSource.data[‘B2SColors’][6] = ‘yellow’
subplotSource.data[‘Text’][6] = ‘Offbottom-Active’
}
if (subplotSource.data[‘B2SColors’][11] != ‘green’){
subplotSource.data[‘B2SColors’][11] = ‘yellow’
subplotSource.data[‘Text’][11] = ‘Offbottom-Completed’
}
}
subplotSource.change.emit()
continue
}
if (novosSource.data[‘type’][i] == ‘UnWeightBit’)
{
if (novosSource.data[‘status’][i] == ‘Active’)
{
subplotSource.data[‘B2SColors’][7] = ‘green’
subplotSource.data[‘Text’][7] = ‘Unweightbit-Active’
} else if (novosSource.data[‘status’][i] == ‘Completed’)
{
console.log(‘-------------------------- B2S 8 Completed--------------------------’)
subplotSource.data[‘B2SColors’][8] = ‘green’
subplotSource.data[‘Text’][8] = ‘Unweightbit-Completed’
} else
{
if (subplotSource.data[‘B2SColors’][7] != ‘green’){
subplotSource.data[‘B2SColors’][7] = ‘yellow’
subplotSource.data[‘Text’][7] = ‘Unweightbit-Active’
}
if (subplotSource.data[‘B2SColors’][8] != ‘green’){
subplotSource.data[‘B2SColors’][8] = ‘yellow’
subplotSource.data[‘Text’][8] = ‘Unweightbit-Completed’
}
}
subplotSource.change.emit()
continue
}
if (novosSource.data[‘type’][i] == ‘ClearBit’)
{
if (novosSource.data[‘status’][i] == ‘Active’)
{
subplotSource.data[‘B2SColors’][9] = ‘green’
subplotSource.data[‘Text’][9] = ‘ClearBit-Active’
} else if (novosSource.data[‘status’][i] == ‘Completed’)
{
console.log(‘-------------------------- B2S 10 Completed--------------------------’)
subplotSource.data[‘B2SColors’][10] = ‘green’
subplotSource.data[‘Text’][10] = ‘ClearBit-Completed’
} else
{
if (subplotSource.data[‘B2SColors’][9] != ‘green’){
subplotSource.data[‘Text’][9] = ‘ClearBit-Active’
subplotSource.data[‘B2SColors’][9] = ‘yellow’
}
if (subplotSource.data[‘B2SColors’][10] != ‘green’){
subplotSource.data[‘Text’][10] = ‘ClearBit-Completed’
subplotSource.data[‘B2SColors’][10] = ‘yellow’
}
}
subplotSource.change.emit()
continue
}
if (novosSource.data[‘type’][i] == ‘CleanHole’)
{
if (novosSource.data[‘status’][i] == ‘Active’)
{
subplotSource.data[‘B2SColors’][0] = ‘green’
subplotSource.data[‘Text’][0] = ‘CleanHole-Active’
} else if (novosSource.data[‘status’][i] == ‘Completed’)
{
console.log(‘-------------------------- B2S 1 Completed--------------------------’)
subplotSource.data[‘B2SColors’][1] = ‘green’
subplotSource.data[‘Text’][1] = ‘CleanHole-Completed’
} else
{
if (subplotSource.data[‘B2SColors’][0] != ‘green’){
subplotSource.data[‘Text’][0] = ‘CleanHole-Active’
subplotSource.data[‘B2SColors’][0] = ‘yellow’
}
if (subplotSource.data[‘B2SColors’][1] != ‘green’){
subplotSource.data[‘Text’][1] = ‘CleanHole-Completed’
subplotSource.data[‘B2SColors’][1] = ‘yellow’
}
}
subplotSource.change.emit()
continue
}
if (novosSource.data[‘type’][i] == ‘SetBoxHeight’)
{
if (novosSource.data[‘status’][i] == ‘Active’)
{
subplotSource.data[‘Text’][2] = ‘SetBoxHeight-Active’
subplotSource.data[‘B2SColors’][2] = ‘green’
} else if (novosSource.data[‘status’][i] == ‘Completed’)
{
console.log(‘-------------------------- B2S 3 Completed--------------------------’)
subplotSource.data[‘Text’][3] = ‘SetBoxHeight-Completed’
subplotSource.data[‘B2SColors’][3] = ‘green’
} else {
if (subplotSource.data[‘B2SColors’][2] != ‘green’){
subplotSource.data[‘Text’][2] = ‘SetBoxHeight-Active’
subplotSource.data[‘B2SColors’][2] = ‘yellow’
}
if (subplotSource.data[‘B2SColors’][3] != ‘green’){
subplotSource.data[‘Text’][3] = ‘SetBoxHeight-Completed’
subplotSource.data[‘B2SColors’][3] = ‘yellow’
}
}
subplotSource.change.emit()
continue
}
if (novosSource.data[‘type’][i] == ‘SetWeight’)
{
if (novosSource.data[‘status’][i] == ‘Active’)
{
subplotSource.data[‘Text’][4] = ‘SetWeight-Active’
subplotSource.data[‘B2SColors’][4] = ‘green’
} else if (novosSource.data[‘status’][i] == ‘Completed’)
{
console.log(‘-------------------------- B2S 5 Completed--------------------------’)
subplotSource.data[‘Text’][5] = ‘SetWeight-Completed’
subplotSource.data[‘B2SColors’][5] = ‘green’
} else {
if (subplotSource.data[‘B2SColors’][4] != ‘green’){
subplotSource.data[‘Text’][4] = ‘SetWeight-Active’
subplotSource.data[‘B2SColors’][4] = ‘yellow’
}
if (subplotSource.data[‘B2SColors’][5] != ‘green’){
subplotSource.data[‘Text’][5] = ‘SetWeight-Completed’
subplotSource.data[‘B2SColors’][5] = ‘yellow’
}
}
subplotSource.change.emit()
continue
}
if (subplotSource.data[‘B2SColors’][0] == ‘red’)
{
subplotSource.data[‘Text’][0] = ‘CleanHole-Active’
}
if (subplotSource.data[‘B2SColors’][1] == ‘red’)
{
subplotSource.data[‘Text’][1] = ‘CleanHole-Completed’
}
if (subplotSource.data[‘B2SColors’][2] == ‘red’)
{
subplotSource.data[‘Text’][2] = ‘SetBoxHeight-Active’
}
if (subplotSource.data[‘B2SColors’][3] == ‘red’)
{
subplotSource.data[‘Text’][3] = ‘SetBoxHeight-Completed’
}
if (subplotSource.data[‘B2SColors’][4] == ‘red’)
{
subplotSource.data[‘Text’][4] = ‘SetWeight-Active’
}
if (subplotSource.data[‘B2SColors’][5] == ‘red’)
{
subplotSource.data[‘Text’][5] = ‘SetWeight-Completed’
}
if (subplotSource.data[‘B2SColors’][6] == ‘red’)
{
subplotSource.data[‘Text’][6] = ‘Offbottom-Active’
}
if (subplotSource.data[‘B2SColors’][7] == ‘red’)
{
subplotSource.data[‘Text’][7] = ‘Unweightbit-Active’
}
if (subplotSource.data[‘B2SColors’][8] == ‘red’)
{
subplotSource.data[‘Text’][8] = ‘Unweightbit-Completed’
}
if (subplotSource.data[‘B2SColors’][9] == ‘red’)
{
subplotSource.data[‘Text’][9] = ‘ClearBit-Active’
}
if (subplotSource.data[‘B2SColors’][10] == ‘red’)
{
subplotSource.data[‘Text’][10] = ‘ClearBit-Completed’
}
if (subplotSource.data[‘B2SColors’][11] == ‘red’)
{
subplotSource.data[‘Text’][11] = ‘Offbottom-Completed’
}
subplotSource.change.emit()
continue
}
}
if(vbarType == ‘S2B’)
{
console.log(‘-------------------------- S2B --------------------------’)
if (novosSource.data[‘connection_phase’][i] == vbarType){
if (novosSource.data[‘type’][i] == ‘AddStand’)
{
console.log(‘-------------------------- S2B AddStand--------------------------’)
if (novosSource.data['status'][i] == 'Active')
{
console.log(‘-------------------------- S2B AddStand Active --------------------------’)
subplotSource.data['Text'][6] = 'AddStand-Active'
subplotSource.data['B2SColors'][6] = 'green'
} else if (novosSource.data['status'][i] == 'Completed')
{
console.log(‘-------------------------- S2B AddStand Completed --------------------------’)
subplotSource.data['Text'][7] = 'AddStand-Completed'
subplotSource.data['B2SColors'][7] = 'green'
} else
{
if (subplotSource.data['B2SColors'][6] != 'green'){
subplotSource.data['Text'][6] = 'AddStand-Active'
subplotSource.data['B2SColors'][6] = 'yellow'
}
if (subplotSource.data['B2SColors'][7] != 'green'){
subplotSource.data['Text'][7] = 'AddStand-Completed'
subplotSource.data['B2SColors'][7] = 'yellow'
}
}
subplotSource.change.emit()
continue
}
if (novosSource.data[‘type’][i] == ‘TakeWeight’)
{
if (novosSource.data[‘status’][i] == ‘Active’)
{
subplotSource.data[‘Text’][8] = ‘TakeWeight-Active’
subplotSource.data[‘B2SColors’][8] = ‘green’
} else if (novosSource.data[‘status’][i] == ‘Completed’)
{
subplotSource.data[‘B2SColors’][9] = ‘green’
subplotSource.data[‘Text’][9] = ‘TakeWeight-Completed’
} else
{
if (subplotSource.data[‘B2SColors’][8] != ‘green’){
subplotSource.data[‘Text’][8] = ‘TakeWeight-Active’
subplotSource.data[‘B2SColors’][8] = ‘yellow’
}
if (subplotSource.data[‘B2SColors’][9] != ‘green’){
subplotSource.data[‘Text’][9] = ‘TakeWeight-Completed’
subplotSource.data[‘B2SColors’][9] = ‘yellow’
}
}
subplotSource.change.emit()
continue
}
if (novosSource.data[‘type’][i] == ‘FlowSetpoint’)
{
if (novosSource.data[‘status’][i] == ‘Active’)
{
subplotSource.data[‘B2SColors’][10] = ‘green’
subplotSource.data[‘Text’][10] = ‘FlowSetpoint-Active’
} else
{
if (subplotSource.data[‘B2SColors’][10] != ‘green’){
subplotSource.data[‘Text’][10] = ‘FlowSetpoint-Active’
subplotSource.data[‘B2SColors’][10] = ‘yellow’
}
}
subplotSource.change.emit()
continue
}
if (novosSource.data[‘type’][i] == ‘RotateDrill’)
{
if (novosSource.data[‘status’][i] == ‘Active’)
{
subplotSource.data[‘Text’][11] = ‘RotateDrill-Active’
subplotSource.data[‘B2SColors’][11] = ‘green’
} else {
if (subplotSource.data[‘B2SColors’][11] != ‘green’)
{
subplotSource.data[‘Text’][11] = ‘RotateDrill-Active’
subplotSource.data[‘B2SColors’][11] = ‘yellow’
}
}
subplotSource.change.emit()
continue
}
if (novosSource.data[‘type’][i] == ‘TagBottom’)
{
if (novosSource.data[‘status’][i] == ‘Active’)
{
console.log(‘--------------------------TagBottom Active --------------------------’)
subplotSource.data[‘Text’][0] = ‘TagBottom-Active’
subplotSource.data[‘B2SColors’][0] = ‘green’
} else if (novosSource.data[‘status’][i] == ‘Completed’)
{
console.log(‘--------------------------TagBottom completed --------------------------’)
subplotSource.data[‘Text’][1] = ‘TagBottom-Completed’
subplotSource.data[‘B2SColors’][1] = ‘green’
} else {
if (subplotSource.data[‘B2SColors’][0] != ‘green’){
subplotSource.data[‘Text’][0] = ‘TagBottom-Active’
subplotSource.data[‘B2SColors’][0] = ‘yellow’
}
if (subplotSource.data[‘B2SColors’][1] != ‘green’){
subplotSource.data[‘Text’][1] = ‘TagBottom-Completed’
subplotSource.data[‘B2SColors’][1] = ‘yellow’
}
}
subplotSource.change.emit()
continue
}
if(subplotSource.data[‘B2SColors’][0] == ‘red’)
{
subplotSource.data[‘Text’][0] = ‘TagBottom-Active’
}
if (subplotSource.data[‘B2SColors’][1] == ‘red’)
{
subplotSource.data[‘Text’][1] = ‘TagBottom-Completed’
}
if (subplotSource.data[‘B2SColors’][6] == ‘red’)
{
subplotSource.data['Text'][6] = 'AddStand-Active'
}
if (subplotSource.data[‘B2SColors’][7] == ‘red’)
{
subplotSource.data['Text'][7] = 'AddStand-Completed'
}
if (subplotSource.data[‘B2SColors’][8] == ‘red’)
{
subplotSource.data[‘Text’][8] = ‘TakeWeight-Active’
}
if (subplotSource.data[‘B2SColors’][9] == ‘red’)
{
subplotSource.data[‘Text’][9] = ‘TakeWeight-Completed’
}
if (subplotSource.data[‘B2SColors’][10] == ‘red’)
{
subplotSource.data[‘Text’][10] = ‘FlowSetpoint-Active’
}
if (subplotSource.data[‘B2SColors’][11] == ‘red’)
{
subplotSource.data[‘Text’][11] = ‘RotateDrill-Active’
}
subplotSource.data[‘B2SColors’][2] = ‘white’
subplotSource.data['B2SColors'][3] = 'white'
subplotSource.data['B2SColors'][4] = 'white'
subplotSource.data['B2SColors'][5] = 'white'
subplotSource.data[‘Text’][2] = ‘’
subplotSource.data[‘Text’][3] = ‘’
subplotSource.data[‘Text’][4] = ‘’
subplotSource.data[‘Text’][5] = ‘’
subplotSource.change.emit()
continue
}
}
if (vbarType == ‘S2S’)
{
console.log(‘-------------------------- s2s --------------------------’)
subplotSource.data['B2SColors'][0] = 'white'
subplotSource.data['B2SColors'][1] = 'white'
subplotSource.data['B2SColors'][2] = 'white'
subplotSource.data['B2SColors'][3] = 'white'
subplotSource.data['B2SColors'][4] = 'white'
subplotSource.data['B2SColors'][5] = 'white'
subplotSource.data['B2SColors'][6] = 'white'
subplotSource.data['B2SColors'][7] = 'white'
subplotSource.data['B2SColors'][8] = 'white'
subplotSource.data['B2SColors'][9] = 'white'
subplotSource.data['B2SColors'][10] = 'white'
subplotSource.data['B2SColors'][11] = 'white'
subplotSource.data['Text'][0] = ''
subplotSource.data['Text'][1] = ''
subplotSource.data['Text'][2] = ''
subplotSource.data['Text'][3] = ''
subplotSource.data['Text'][4] = ''
subplotSource.data['Text'][5] = ''
subplotSource.data['Text'][6] = ''
subplotSource.data['Text'][7] = ''
subplotSource.data['Text'][8] = ''
subplotSource.data['Text'][9] = ''
subplotSource.data['Text'][10] = ''
subplotSource.data['Text'][11] = ''
subplotSource.change.emit()
continue
}
}
}
}
“”"
subplot_colors_length = len(subplot_dict[‘B2SColors’])
novos_length = len(novos_connection_dict[depth_ft_str])
taptool.callback = CustomJS(args=dict(allSource=mainplot_source, novosSource=novos_source, subplotSource=subplot_source, subplotColorsLength=subplot_colors_length, novosLength=novos_length,subplot=subplot),code=code)
hide_subplot_callback = CustomJS(args=dict(m_color=m_color_white, subplot=subplot, subplotColorsLength=subplot_colors_length, subplotSource=subplot_source), code=“”"
for(i = 0; i < subplotColorsLength; i++) {
subplotSource.data[‘B2SColors’][i] = ‘white’
subplotSource.data[‘B2STextColors’][i] = ‘white’
}
subplotSource.change.emit()
subplot.background_fill_color = ‘white’
“”")
main_plot.js_on_event(events.DoubleTap, hide_subplot_callback)
layout
m_well_selection = Div(text=‘Well Selection:’, height=1)
m_well_connection = Div(text=‘Connection Type:’, height=1)
m_well_conn_phase = Div(text=‘Connection Phase:’, height=1)
‘’’
column_well_selection = column(children=[m_well_selection,checkbox_group_1], sizing_mode=‘scale_width’)
column_1 = column(children=[rigs_combx, column_well_selection], sizing_mode=‘scale_both’)
column_connection_type = column(children=[m_well_connection, checkbox_group_2], sizing_mode=‘scale_width’)
column_2 = column(children=[jobs_combx, column_connection_type], sizing_mode=‘scale_both’)
column_connection_phase = column(children=[m_well_conn_phase, checkbox_group_3], sizing_mode=‘scale_width’)
column_3 = column(children=[crewshift_combx, column_connection_phase], sizing_mode=‘scale_both’)
row_1 = row(children=[column_1, column_2, column_3], sizing_mode=‘scale_width’)
column_4 = column(children=[row_1,], sizing_mode=‘scale_width’)
‘’’
spacer_1 = Spacer(width=300, height=100)
spacer_2 = Spacer(width=300, height=100)
#column_well_selection_layout = layout(column(children=[m_well_selection,checkbox_group_1], sizing_mode=‘scale_both’))
menu_column_1_layout = column(rigs_combx, m_well_selection,checkbox_group_1)
#column_connection_type_layout = layout(column(children=[m_well_connection, checkbox_group_2], sizing_mode=‘scale_both’))
menu_column_2_layout = column(jobs_combx, m_well_connection, checkbox_group_2)
#column_connection_phase_layout = layout(column(children=[m_well_conn_phase, checkbox_group_3], sizing_mode=‘scale_both’))
menu_column_3_layout = column(crewshift_combx, m_well_conn_phase, checkbox_group_3)
#row_1 = row(children=[column_1, column_2, column_3], sizing_mode=‘scale_width’)
menu_layout = layout(row(menu_column_1_layout, spacer_1, menu_column_2_layout, spacer_2, menu_column_3_layout))
main_layout = column(children=[menu_layout, summary_layout, main_plot, subplot], sizing_mode=‘scale_width’)
doc.add_root(main_layout)
doc.theme = Theme(filename=“theme.yaml”)
``
On Thursday, July 12, 2018 at 12:29:16 PM UTC-6, Bryan Van de ven wrote:
That JS script loads a new session from the server, which means the server runs the app code, e.g. the code in an app.py script, or a main.py in “dir style” app, or executes a modify_doc(doc) function if you’ve embedded a Bokeh server as a library inside the flask app. The reason it takes any amount of time, whatever amount of time it takes, is because that’s how long your app code takes to execute. Without knowing anything at all about the app code, it’s not possible to say anything more.
Thanks,
Bryan
On Jul 12, 2018, at 13:20, peng wang [email protected] wrote:
Hi Guys,
My web application is Flask + Bokeh Server. It takes around 40 seconds to launch the application. I investigated this issue and like to post screenshot below. Could someone take a look and explain why autoload.js***** consumes so much time(16s). thanks a lot.
–
You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/ffec2332-6337-49ff-8279-d60a8d1dbb81%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.