hi
I AM Working on dashboard which is dynamic based upon select,it render plot
my problem if i render circle plot it display multiple circle lines correspondinmg to legends
but when i display lines .only one line is shown coonecting all the circles ( which i dont want)
any bug in y code?
Thanks for your help in advance
from bokeh.io import curdoc
import itertools from bokeh.transform import factor_cmap, factor_mark
import pandas as pd
import bokeh
from bokeh.layouts import row,gridplot,widgetbox,column
from bokeh.io import output_notebook
from bokeh.palettes import Category20
from bokeh.plotting import figure, output_file, show
from bokeh.models import Select,ColumnDataSource,HoverTool,BoxZoomTool, ResetTool, CrosshairTool, BoxSelectTool, WheelZoomTool,Legend,MultiSelect
df=pd.read_excel('D:/LRD_4_General.xlsx')
df=df.sort_values('bh_date')
df = df.reset_index(drop=True)
df_lrd=sorted(df.lrd_4.unique().astype(str).tolist())
df_sec=sorted(df.sec.unique().astype(str).tolist())
df_cell=sorted(df.cell_name_new.unique().astype(str).tolist())
select1 = Select(title="SIte",options=df_lrd,value=df_lrd[0])
select2 = Select(title="sec",options=df_sec,value=df_sec[0])
select3 = Select(title="cell",options=df_cell,value=df_cell[0])
# select3 = MultiSelect(title="cell:", options=df_cell,value=list(df_cell))
source=ColumnDataSource(df)
cell_cmp = factor_cmap('cell_name_new',palette=Category20[20]*len(df_cell),factors=df_cell)
hover=HoverTool(
tooltips=[
( 'date', '@bh_date{%F}' ),
( 'cell', '@cell_name_new' ), # use @{ } for field names with spaces
( 'user', '@avg_user_number{0.0 a}' ),
],
formatters={
'bh_date' : 'datetime', # use 'datetime' formatter for 'date' field
# 'adj close' : 'printf', # use 'printf' formatter for 'adj close' field
# use default 'numeral' formatter for other fields
},
# display a tooltip whenever the cursor is vertically in line with a glyph
mode='vline'
)
tools = [hover, BoxZoomTool(), ResetTool(), CrosshairTool(), BoxSelectTool(), WheelZoomTool()]
p = figure(x_axis_type="datetime", title='SITE_NAME', width = 800, height = 450,tools=tools,sizing_mode="scale_width")
p.line(x='bh_date',y='avg_user_number',legend_field='cell_name_new',line_width=2,line_dash='solid',source=source,color='olive')
p.scatter(x='bh_date',y='avg_user_number',source=source,legend_field='cell_name_new',line_color=cell_cmp,fill_color=cell_cmp)
p.xaxis.axis_label = 'bh_date'
p.yaxis.axis_label = '<users in k>'
p.legend.location = "top_left"
p.legend.click_policy="hide"
def update_site(attr,old,new):
select1.value==select1.options
df_new=df[df.lrd_4==select1.value]
select2.options=sorted(df_new.sec.unique().tolist())
select3.options=sorted(df_new.cell_name_new.unique().tolist())
source.data=df_new
def update_sec(attr,old,new):
select3.value==select2.options
df_sec_new=df[df.sec==select2.value]
select3.options=df_sec_new.cell_name_new.unique().tolist()
source.data=df_sec_new
def update_cell(attr,old,new):
select3.value==select3.options
df_cell_new=df[df.cell_name_new==select3.value]
source.data=df_cell_new
# Attach the update_plot callback to the 'value' p roperty of select
select1.on_change('value', update_site)
select2.on_change('value', update_sec)
select3.on_change('value', update_cell)
controls = column(select1, select2, select3, width=200)
layout = row(controls,p)
curdoc().add_root(layout)
curdoc().title = "SK_JADOO"