OTW compare only uses data on course
This commit is contained in:
@@ -5045,7 +5045,7 @@ def interactive_bar_chart(id=0,promember=0):
|
|||||||
|
|
||||||
def interactive_multiple_compare_chart(ids,xparam,yparam,plottype='line',
|
def interactive_multiple_compare_chart(ids,xparam,yparam,plottype='line',
|
||||||
promember=0,
|
promember=0,
|
||||||
labeldict=None):
|
labeldict=None,startenddict={}):
|
||||||
|
|
||||||
message = ''
|
message = ''
|
||||||
errormessage = ''
|
errormessage = ''
|
||||||
@@ -5085,9 +5085,13 @@ def interactive_multiple_compare_chart(ids,xparam,yparam,plottype='line',
|
|||||||
if xparam != 'distance' and xparam != 'time' and xparam != 'cumdist':
|
if xparam != 'distance' and xparam != 'time' and xparam != 'cumdist':
|
||||||
xaxmax = yaxmaxima[xparam]
|
xaxmax = yaxmaxima[xparam]
|
||||||
xaxmin = yaxminima[xparam]
|
xaxmin = yaxminima[xparam]
|
||||||
elif xparam == 'time':
|
elif xparam == 'time' and not startenddict:
|
||||||
xaxmax = tseconds.max()
|
xaxmax = tseconds.max()
|
||||||
xaxmin = tseconds.min()
|
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:
|
else:
|
||||||
xaxmax = datadf['distance'].max()
|
xaxmax = datadf['distance'].max()
|
||||||
xaxmin = datadf['distance'].min()
|
xaxmin = datadf['distance'].min()
|
||||||
@@ -5170,10 +5174,27 @@ def interactive_multiple_compare_chart(ids,xparam,yparam,plottype='line',
|
|||||||
|
|
||||||
for id,color in items:
|
for id,color in items:
|
||||||
group = datadf[datadf['workoutid']==int(id)].copy()
|
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.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':
|
if xparam == 'cumdist':
|
||||||
|
group['cumdist'] = group['cumdist'] - group['cumdist'].min()
|
||||||
res = make_cumvalues(group[xparam])
|
res = make_cumvalues(group[xparam])
|
||||||
group[xparam] = res[0]
|
group[xparam] = res[0]
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -1524,6 +1524,12 @@ def virtualevent_compare_view(request,id=0):
|
|||||||
|
|
||||||
workoutids = [result.workoutid for result in results]
|
workoutids = [result.workoutid for result in results]
|
||||||
|
|
||||||
|
startenddict = {}
|
||||||
|
for result in results:
|
||||||
|
startenddict[result.workoutid] = (result.startsecond,result.endsecond)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if len(workoutids) == 0:
|
if len(workoutids) == 0:
|
||||||
url = reverse('virtualevent_view',
|
url = reverse('virtualevent_view',
|
||||||
kwargs={
|
kwargs={
|
||||||
@@ -1555,10 +1561,13 @@ def virtualevent_compare_view(request,id=0):
|
|||||||
except Workout.DoesNotExist:
|
except Workout.DoesNotExist:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
labeldict = {
|
labeldict = {
|
||||||
int(w.id): w.__str__() for w in workouts
|
int(w.id): w.__str__() for w in workouts
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
chartform = ChartParamChoiceForm(
|
chartform = ChartParamChoiceForm(
|
||||||
initial = {
|
initial = {
|
||||||
'xparam':xparam,
|
'xparam':xparam,
|
||||||
@@ -1584,7 +1593,7 @@ def virtualevent_compare_view(request,id=0):
|
|||||||
for id in workoutids:
|
for id in workoutids:
|
||||||
try:
|
try:
|
||||||
workouts.append(Workout.objects.get(
|
workouts.append(Workout.objects.get(
|
||||||
id=encoder.decode_hex(id)))
|
id=id))
|
||||||
except Workout.DoesNotExist:
|
except Workout.DoesNotExist:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@@ -1598,7 +1607,7 @@ def virtualevent_compare_view(request,id=0):
|
|||||||
res = interactive_multiple_compare_chart(workoutids,xparam,yparam,
|
res = interactive_multiple_compare_chart(workoutids,xparam,yparam,
|
||||||
promember=promember,
|
promember=promember,
|
||||||
plottype=plottype,
|
plottype=plottype,
|
||||||
labeldict=labeldict)
|
labeldict=labeldict,startenddict=startenddict)
|
||||||
script = res[0]
|
script = res[0]
|
||||||
div = res[1]
|
div = res[1]
|
||||||
errormessage = res[3]
|
errormessage = res[3]
|
||||||
|
|||||||
Reference in New Issue
Block a user