【发布时间】:2022-01-24 01:11:48
【问题描述】:
我正在 VS 代码 中构建一个 Bokeh 应用程序,每当我点击运行(右上角的绿色箭头)时,更改都会打开一个新浏览器。我认为这很容易实现,但我正在努力寻找一种方法,即每次进行更改时都可以刷新同一个浏览器,而不是每次点击运行时都打开一个新浏览器,例如
有没有类似于 Live Server 用于 html 文件的方法?如果有帮助,我的散景应用程序的代码如下所示
from random import random
from bokeh.layouts import column, row, widgetbox, layout
from bokeh.models import Button
from bokeh.palettes import RdYlBu3
from bokeh.plotting import figure, curdoc
import pandas as pd
import pyodbc
from bokeh.plotting import figure, output_file, show, save
from bokeh.models import ColumnDataSource, HoverTool, CategoricalColorMapper, Legend, PrintfTickFormatter, CustomJS, Select
from bokeh.models.widgets import (Select)
from bokeh.models.widgets import Div
### Read in the data
df = pd.read_excel('RS data.xlsx')
### Set up Figure
p = figure(x_range=(0, 20), y_range=(0, 10), plot_height=400, plot_width=800)
p.add_layout(Legend(), 'right')
p.toolbar_location = None
df['Unique Story Count'] = df.groupby(['Person','Sprint'])['Story Id'].transform('nunique')
### Convert data into a bokeh data type
df1 = df[['Person', 'Sprint', 'Unique Story Count']]
df1['Person'].unique()
df1 = df1[df1['Person'] == 'Analyst 1'].drop_duplicates()
source1 = ColumnDataSource(df1)
x='Sprint'
y='Unique Story Count'
p1 = p.line(
x=x, y=y,
color='#d96ad5', line_color='#d96ad5',
line_width=2, line_alpha=1, source=source1
)
p2 = p.circle(
x=x,
y=y,
#legend_label='',
size=6,
fill_alpha=1,
# color={'field': 'Submission', 'transform': mapper},
source=source1
)
p.xaxis.ticker = list(range(0, 21))
p.xgrid.ticker = list(range(0, 21))
p.xaxis.axis_label = 'Sprint'
p.yaxis.axis_label = 'Story Count'
## tooltip for point
p.add_tools(HoverTool(
renderers=[p2],
tooltips=[
('Spri Num', '@Sprint'),
('Story Count', '@{Unique Story Count}')
],
mode='mouse')
)
show(p)
【问题讨论】:
标签: python visual-studio-code bokeh