From 0c225126d21ca8740ac9c41b1d487163ad35478c Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Tue, 23 Oct 2018 21:33:23 +0200 Subject: [PATCH] fixed bug with disappearing div --- rowers/interactiveplots.py | 15 +++++++++------ rowers/templates/multicompare.html | 4 +++- rowers/views.py | 2 +- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/rowers/interactiveplots.py b/rowers/interactiveplots.py index 303e0cb0..655e7f37 100644 --- a/rowers/interactiveplots.py +++ b/rowers/interactiveplots.py @@ -319,7 +319,7 @@ def interactive_activitychart(workouts,startdate,enddate,stack='type'): p.legend.location = "top_left" p.legend.background_fill_alpha = 0.7 - # p.sizing_mode = 'scale_width' + #p.sizing_mode = 'scale_width' p.sizing_mode = 'stretch_both' p.yaxis.axis_label = 'Minutes' @@ -3733,11 +3733,12 @@ def interactive_multiple_compare_chart(ids,xparam,yparam,plottype='line', 'power','hr','spm', 'time','pace','workoutstate', 'workoutid'] - + datadf = dataprep.getsmallrowdata_db(columns,ids=ids) datadf.dropna(axis=1,how='all',inplace=True) datadf.dropna(axis=0,how='any',inplace=True) + nrworkouts = len(ids) try: @@ -3800,13 +3801,14 @@ def interactive_multiple_compare_chart(ids,xparam,yparam,plottype='line', plot = Figure(x_axis_type=x_axis_type,y_axis_type=y_axis_type, tools=TOOLS, toolbar_location="above", - plot_width=920, + plot_width=920,plot_height=500, toolbar_sticky=False) # add watermark plot.extra_y_ranges = {"watermark": watermarkrange} plot.extra_x_ranges = {"watermark": watermarkrange} - plot.sizing_mode = 'stretch_both' + plot.sizing_mode = 'scale_width' + plot.image_url([watermarkurl],0.05,0.9, watermarkw,watermarkh, @@ -3826,6 +3828,8 @@ def interactive_multiple_compare_chart(ids,xparam,yparam,plottype='line', for id,color in itertools.izip(ids,colors): group = datadf[datadf['workoutid']==int(id)].copy() + + group.sort_values(by='time',ascending=True,inplace=True) try: group['x'] = group[xparam] @@ -3837,6 +3841,7 @@ def interactive_multiple_compare_chart(ids,xparam,yparam,plottype='line', except KeyError: group['y'] = 0.0*group['x'] + ymean = group['y'].mean() ylabel = Label(x=100,y=60+nrworkouts*20-20*cntr, x_units='screen',y_units='screen', @@ -3909,8 +3914,6 @@ def interactive_multiple_compare_chart(ids,xparam,yparam,plottype='line', script, div = components(plot) - - return [script,div,message,errormessage] diff --git a/rowers/templates/multicompare.html b/rowers/templates/multicompare.html index e3e32d7b..ae0fbe49 100644 --- a/rowers/templates/multicompare.html +++ b/rowers/templates/multicompare.html @@ -14,12 +14,14 @@ {{ interactiveplot |safe }}

Interactive Comparison

+ +
  • -
    {{ the_div|safe }}
    +
  • diff --git a/rowers/views.py b/rowers/views.py index 846ff465..9bfbde2c 100644 --- a/rowers/views.py +++ b/rowers/views.py @@ -5376,7 +5376,7 @@ def multi_compare_view(request): labeldict = { int(w.id): w.__unicode__() for w in workouts } - + res = interactive_multiple_compare_chart(ids,xparam,yparam, promember=promember, plottype=plottype,