/
bokeh_file_read.py
66 lines (48 loc) · 1.55 KB
/
bokeh_file_read.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat May 9 22:06:13 2020
@author: lukishyadav
"""
from bokeh.io import curdoc
from bokeh.models.widgets import FileInput
from pybase64 import b64decode
import pandas as pd
import io
from bokeh.models.widgets import Button, RadioButtonGroup, Select, Slider,TextInput,TextAreaInput
from bokeh.layouts import column,layout,row,widgetbox
from bokeh.plotting import figure, output_file, show
def upload_fit_data(attr, old, new):
print("fit data upload succeeded")
decoded = b64decode(new)
f = io.BytesIO(decoded)
global df
print(type(new))
df = pd.read_csv(f)
#print(new_df)
file_input = FileInput(accept=".csv,.json,.txt,.pdf,.xls")
file_input.on_change('value', upload_fit_data)
p = figure(
# x_range=(minlng,maxlng),
# y_range=(minlat, maxlat),
#x_axis_type=map_repr,
#y_axis_type=map_repr,
#title='IDLE Vehicles Map',
match_aspect=True,
tools="pan,wheel_zoom,box_zoom,tap,box_select,reset,save"
#tools='tap'
)
p.circle(x=[], y=[],
#size=cluster_point_size,
fill_alpha=0.2,
color="royalblue",line_alpha=0
#line_color='black'
)
def update_click():
global df
p.circle(x=df['end_long'], y=df['end_lat'], fill_alpha=0.2,color="royalblue",line_alpha=0)
#p.circle(x=[], y=[], fill_alpha=0.2,color="royalblue",line_alpha=0)
bt = Button(label='Update Plot')
bt.on_click(update_click)
doc=curdoc()
doc.add_root(layout(row(file_input,p,bt)))