Private
Public Access
1
0

adding slider annotation to box chart

This commit is contained in:
Sander Roosendaal
2019-03-31 17:07:44 +02:00
parent b97990b905
commit 64cb556730
2 changed files with 16 additions and 11 deletions

View File

@@ -164,7 +164,8 @@ def tailwind(bearing,vwind,winddir):
from rowers.dataprep import nicepaceformat,niceformat
from rowers.dataprep import timedeltaconv
def interactive_boxchart(datadf,fieldname,extratitle=''):
def interactive_boxchart(datadf,fieldname,extratitle='',
spmmin=0,spmmax=0,workmin=0,workmax=0):
if datadf.empty:
return '','It looks like there are no data matching your filter'
@@ -186,15 +187,6 @@ def interactive_boxchart(datadf,fieldname,extratitle=''):
plot = hv.render(boxwhiskers)
#plot = BoxPlot(datadf, values=fieldname, label='date',
# legend=False,
# title=axlabels[fieldname]+' '+extratitle,
# outliers=False,
# tools=TOOLS,
# toolbar_location="above",
# toolbar_sticky=False,
# x_mapper_type='datetime',plot_width=920)
yrange1 = Range1d(start=yaxminima[fieldname],end=yaxmaxima[fieldname])
plot.y_range = yrange1
plot.sizing_mode = 'scale_width'
@@ -221,6 +213,18 @@ def interactive_boxchart(datadf,fieldname,extratitle=''):
plot.plot_width=920
plot.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

View File

@@ -3087,7 +3087,8 @@ def boxplot_view_data(request,userid=0,
script,div = interactive_boxchart(datadf,plotfield,
extratitle=extratitle)
extratitle=extratitle,
spmmin=spmmin,spmmax=spmmax,workmin=workmin,workmax=workmax)
scripta = script.split('\n')[2:-1]
script = ''.join(scripta)