CP chart data points are now clickable
This commit is contained in:
@@ -1243,28 +1243,30 @@ def fetchcp_new(rower,workouts):
|
|||||||
try:
|
try:
|
||||||
df = pd.read_parquet(cpfile)
|
df = pd.read_parquet(cpfile)
|
||||||
df['workout'] = str(workout)
|
df['workout'] = str(workout)
|
||||||
|
df['url'] = workout.url()
|
||||||
data.append(df)
|
data.append(df)
|
||||||
except:
|
except:
|
||||||
# CP data file doesn't exist yet. has to be created
|
# CP data file doesn't exist yet. has to be created
|
||||||
df, delta, cpvalues = setcp(workout)
|
df, delta, cpvalues = setcp(workout)
|
||||||
df['workout'] = str(workout)
|
df['workout'] = str(workout)
|
||||||
|
df['url'] = workout.url()
|
||||||
data.append(df)
|
data.append(df)
|
||||||
|
|
||||||
|
|
||||||
if len(data) == 0:
|
if len(data) == 0:
|
||||||
return pd.Series(),pd.Series(),0,pd.Series()
|
return pd.Series(),pd.Series(),0,pd.Series(),pd.Series()
|
||||||
if len(data)>1:
|
if len(data)>1:
|
||||||
df = pd.concat(data,axis=0)
|
df = pd.concat(data,axis=0)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
df = df[df['cp'] == df.groupby(['delta'])['cp'].transform('max')]
|
df = df[df['cp'] == df.groupby(['delta'])['cp'].transform('max')]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pd.Series(),pd.Series(),0,pd.DataFrame()
|
pd.Series(),pd.Series(),0,pd.Series(),pd.Series()
|
||||||
|
|
||||||
|
|
||||||
df = df.sort_values(['delta']).reset_index()
|
df = df.sort_values(['delta']).reset_index()
|
||||||
|
|
||||||
return df['delta'],df['cp'],0,df['workout']
|
return df['delta'],df['cp'],0,df['workout'],df['url']
|
||||||
|
|
||||||
def setcp(workout,background=False,recurrance=True):
|
def setcp(workout,background=False,recurrance=True):
|
||||||
filename = 'media/cpdata_{id}.parquet.gz'.format(id=workout.id)
|
filename = 'media/cpdata_{id}.parquet.gz'.format(id=workout.id)
|
||||||
|
|||||||
@@ -3896,6 +3896,8 @@ def interactive_otwcpchart(powerdf,promember=0,rowername="",r=None,cpfit='data',
|
|||||||
deltas = fitt.apply(lambda x: timedeltaconv(x))
|
deltas = fitt.apply(lambda x: timedeltaconv(x))
|
||||||
ftime = niceformat(deltas)
|
ftime = niceformat(deltas)
|
||||||
workouts = powerdf['workout']
|
workouts = powerdf['workout']
|
||||||
|
urls = powerdf['url']
|
||||||
|
|
||||||
|
|
||||||
sourcecomplex = ColumnDataSource(
|
sourcecomplex = ColumnDataSource(
|
||||||
data = dict(
|
data = dict(
|
||||||
@@ -3904,6 +3906,7 @@ def interactive_otwcpchart(powerdf,promember=0,rowername="",r=None,cpfit='data',
|
|||||||
duration = fitt/60.,
|
duration = fitt/60.,
|
||||||
ftime = ftime,
|
ftime = ftime,
|
||||||
workout = workouts,
|
workout = workouts,
|
||||||
|
url = urls,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -3967,6 +3970,9 @@ def interactive_otwcpchart(powerdf,promember=0,rowername="",r=None,cpfit='data',
|
|||||||
|
|
||||||
hover.mode = 'mouse'
|
hover.mode = 'mouse'
|
||||||
|
|
||||||
|
taptool = plot.select(type=TapTool)
|
||||||
|
taptool.callback = OpenURL(url='@url')
|
||||||
|
|
||||||
plot.line('duration','CP',source=sourcecomplex,legend_label="CP Model",
|
plot.line('duration','CP',source=sourcecomplex,legend_label="CP Model",
|
||||||
color='green')
|
color='green')
|
||||||
|
|
||||||
|
|||||||
@@ -525,12 +525,13 @@ def cpdata(workouts, options):
|
|||||||
|
|
||||||
|
|
||||||
ids = [w.id for w in workouts]
|
ids = [w.id for w in workouts]
|
||||||
delta, cpvalue, avgpower,workoutnames = dataprep.fetchcp_new(r,workouts)
|
delta, cpvalue, avgpower,workoutnames,urls = dataprep.fetchcp_new(r,workouts)
|
||||||
|
|
||||||
powerdf = pd.DataFrame({
|
powerdf = pd.DataFrame({
|
||||||
'Delta':delta,
|
'Delta':delta,
|
||||||
'CP':cpvalue,
|
'CP':cpvalue,
|
||||||
'workout':workoutnames,
|
'workout':workoutnames,
|
||||||
|
'url':urls,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user