working,added save canvas
This commit is contained in:
@@ -18,6 +18,7 @@ import rowers.metrics as metrics
|
||||
import rowers.dataprep as dataprep
|
||||
from rowers.dataprep import rdata
|
||||
import rowers.utils as utils
|
||||
from jsmin import jsmin
|
||||
|
||||
from scipy.interpolate import griddata
|
||||
from scipy.signal import savgol_filter
|
||||
@@ -116,6 +117,10 @@ def get_chart(end_point, chart_data, debug=False):
|
||||
except AttributeError:
|
||||
div = 'The chart server errored'
|
||||
|
||||
|
||||
#if not debug:
|
||||
# script = jsmin(script)
|
||||
|
||||
return script, div
|
||||
|
||||
# Example for 3D
|
||||
@@ -415,67 +420,6 @@ def interactive_boxchart(datadf, fieldname, extratitle='',
|
||||
script, div = get_chart("/boxplot", boxplot_data)
|
||||
return script, div
|
||||
|
||||
tooltips = [
|
||||
('Value', '@'+fieldname),
|
||||
]
|
||||
|
||||
hover = HoverTool(tooltips=tooltips)
|
||||
|
||||
TOOLS = [hover]
|
||||
|
||||
hv.extension('bokeh')
|
||||
|
||||
try:
|
||||
boxwhiskers = hv.BoxWhisker(datadf, 'date', fieldname)
|
||||
boxwhiskers.opts(tools=TOOLS, outlier_color='white')
|
||||
except DataError: # pragma: no cover
|
||||
return "", "Invalid Data"
|
||||
|
||||
plot = hv.render(boxwhiskers)
|
||||
|
||||
yrange1 = Range1d(start=yaxminima[fieldname], end=yaxmaxima[fieldname])
|
||||
plot.y_range = yrange1
|
||||
#plot.sizing_mode = 'stretch_both'
|
||||
|
||||
if extratitle:
|
||||
plot.title.text = extratitle
|
||||
|
||||
plot.xaxis.axis_label = 'Date'
|
||||
plot.yaxis.axis_label = axlabels[fieldname]
|
||||
|
||||
plot.xaxis.formatter = DatetimeTickFormatter(
|
||||
days=["%d %B %Y"],
|
||||
months=["%d %B %Y"],
|
||||
years=["%d %B %Y"],
|
||||
)
|
||||
|
||||
if fieldname == 'pace': # pragma: no cover
|
||||
plot.yaxis[0].formatter = DatetimeTickFormatter(
|
||||
seconds=["%S"],
|
||||
minutes=["%M"]
|
||||
)
|
||||
|
||||
plot.xaxis.major_label_orientation = pi/4
|
||||
|
||||
plot.width = 920
|
||||
plot.height = 600
|
||||
|
||||
slidertext = 'SPM: {:.0f}-{:.0f}, WpS: {:.0f}-{:.0f}'.format(
|
||||
spmmin, spmmax, workmin, workmax
|
||||
)
|
||||
sliderlabel = Label(x=50, y=20, x_units='screen', y_units='screen',
|
||||
text=slidertext,
|
||||
background_fill_alpha=0.7,
|
||||
background_fill_color='white',
|
||||
text_color='black', text_font_size='10pt',
|
||||
)
|
||||
|
||||
plot.add_layout(sliderlabel)
|
||||
|
||||
script, div = components(plot)
|
||||
|
||||
return script, div
|
||||
|
||||
|
||||
def interactive_planchart(data, startdate, enddate):
|
||||
hv.extension('bokeh')
|
||||
|
||||
Reference in New Issue
Block a user