adding slider annotation to box chart
This commit is contained in:
@@ -164,7 +164,8 @@ def tailwind(bearing,vwind,winddir):
|
|||||||
from rowers.dataprep import nicepaceformat,niceformat
|
from rowers.dataprep import nicepaceformat,niceformat
|
||||||
from rowers.dataprep import timedeltaconv
|
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:
|
if datadf.empty:
|
||||||
return '','It looks like there are no data matching your filter'
|
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 = 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])
|
yrange1 = Range1d(start=yaxminima[fieldname],end=yaxmaxima[fieldname])
|
||||||
plot.y_range = yrange1
|
plot.y_range = yrange1
|
||||||
plot.sizing_mode = 'scale_width'
|
plot.sizing_mode = 'scale_width'
|
||||||
@@ -221,6 +213,18 @@ def interactive_boxchart(datadf,fieldname,extratitle=''):
|
|||||||
plot.plot_width=920
|
plot.plot_width=920
|
||||||
plot.plot_height=600
|
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)
|
script, div = components(plot)
|
||||||
|
|
||||||
return script,div
|
return script,div
|
||||||
|
|||||||
@@ -3087,7 +3087,8 @@ def boxplot_view_data(request,userid=0,
|
|||||||
|
|
||||||
|
|
||||||
script,div = interactive_boxchart(datadf,plotfield,
|
script,div = interactive_boxchart(datadf,plotfield,
|
||||||
extratitle=extratitle)
|
extratitle=extratitle,
|
||||||
|
spmmin=spmmin,spmmax=spmmax,workmin=workmin,workmax=workmax)
|
||||||
|
|
||||||
scripta = script.split('\n')[2:-1]
|
scripta = script.split('\n')[2:-1]
|
||||||
script = ''.join(scripta)
|
script = ''.join(scripta)
|
||||||
|
|||||||
Reference in New Issue
Block a user