Private
Public Access
1
0

OTW compare only uses data on course

This commit is contained in:
Sander Roosendaal
2020-05-24 17:11:41 +02:00
parent 36656b3c73
commit c3b404f8b6
2 changed files with 34 additions and 4 deletions

View File

@@ -5045,7 +5045,7 @@ def interactive_bar_chart(id=0,promember=0):
def interactive_multiple_compare_chart(ids,xparam,yparam,plottype='line',
promember=0,
labeldict=None):
labeldict=None,startenddict={}):
message = ''
errormessage = ''
@@ -5085,9 +5085,13 @@ def interactive_multiple_compare_chart(ids,xparam,yparam,plottype='line',
if xparam != 'distance' and xparam != 'time' and xparam != 'cumdist':
xaxmax = yaxmaxima[xparam]
xaxmin = yaxminima[xparam]
elif xparam == 'time':
elif xparam == 'time' and not startenddict:
xaxmax = tseconds.max()
xaxmin = tseconds.min()
elif xparam == 'time' and startenddict:
deltas = [pair[1]-pair[0] for key,pair in startenddict.items()]
xaxmin = 0
xaxmax = pd.Series(deltas).max()*1000.
else:
xaxmax = datadf['distance'].max()
xaxmin = datadf['distance'].min()
@@ -5170,10 +5174,27 @@ def interactive_multiple_compare_chart(ids,xparam,yparam,plottype='line',
for id,color in items:
group = datadf[datadf['workoutid']==int(id)].copy()
try:
startsecond,endsecond = startenddict[id]
except KeyError:
startsecond = 0
endsecond = 0
group.sort_values(by='time',ascending=True,inplace=True)
group['time'] = group['time'] - 1.e3*startsecond
mask = group['time'] < 0
group.mask(mask,inplace=True)
mask = group['time'] > 1.e3*(endsecond-startsecond)
group.mask(mask,inplace=True)
if xparam == 'cumdist':
group['cumdist'] = group['cumdist'] - group['cumdist'].min()
res = make_cumvalues(group[xparam])
group[xparam] = res[0]
try:

View File

@@ -1524,6 +1524,12 @@ def virtualevent_compare_view(request,id=0):
workoutids = [result.workoutid for result in results]
startenddict = {}
for result in results:
startenddict[result.workoutid] = (result.startsecond,result.endsecond)
if len(workoutids) == 0:
url = reverse('virtualevent_view',
kwargs={
@@ -1555,10 +1561,13 @@ def virtualevent_compare_view(request,id=0):
except Workout.DoesNotExist:
pass
labeldict = {
int(w.id): w.__str__() for w in workouts
}
chartform = ChartParamChoiceForm(
initial = {
'xparam':xparam,
@@ -1584,7 +1593,7 @@ def virtualevent_compare_view(request,id=0):
for id in workoutids:
try:
workouts.append(Workout.objects.get(
id=encoder.decode_hex(id)))
id=id))
except Workout.DoesNotExist:
pass
@@ -1598,7 +1607,7 @@ def virtualevent_compare_view(request,id=0):
res = interactive_multiple_compare_chart(workoutids,xparam,yparam,
promember=promember,
plottype=plottype,
labeldict=labeldict)
labeldict=labeldict,startenddict=startenddict)
script = res[0]
div = res[1]
errormessage = res[3]