adding workout name to cp chart hover
This commit is contained in:
@@ -1023,14 +1023,17 @@ def fetchcp_new(rower,workouts):
|
||||
cpfile = 'media/cpdata_{id}.parquet.gz'.format(id=workout.id)
|
||||
try:
|
||||
df = pd.read_parquet(cpfile)
|
||||
df['workout'] = str(workout)
|
||||
data.append(df)
|
||||
except OSError:
|
||||
# CP data file doesn't exist yet. has to be created
|
||||
data.append(setcp(workout)[0])
|
||||
df, delta, cpvalues = setcp(workout)
|
||||
df['workout'] = str(workout)
|
||||
data.append(df)
|
||||
|
||||
|
||||
if len(data) == 0:
|
||||
return pd.Series(),pd.Series(),0
|
||||
return pd.Series(),pd.Series(),0,pd.Series()
|
||||
if len(data)>1:
|
||||
df = pd.concat(data,axis=0)
|
||||
|
||||
@@ -1039,7 +1042,7 @@ def fetchcp_new(rower,workouts):
|
||||
|
||||
df = df.sort_values(['delta']).reset_index()
|
||||
|
||||
return df['delta'],df['cp'],0
|
||||
return df['delta'],df['cp'],0,df['workout']
|
||||
|
||||
def setcp(workout):
|
||||
strokesdf = getsmallrowdata_db(['power','workoutid','time'],ids = [workout.id])
|
||||
|
||||
@@ -2921,13 +2921,15 @@ def interactive_otwcpchart(powerdf,promember=0,rowername="",r=None,cpfit='data')
|
||||
|
||||
deltas = fitt.apply(lambda x: timedeltaconv(x))
|
||||
ftime = niceformat(deltas)
|
||||
workouts = powerdf['workout']
|
||||
|
||||
sourcecomplex = ColumnDataSource(
|
||||
data = dict(
|
||||
CP = fitpower,
|
||||
CPmax = ratio*fitpower,
|
||||
duration = fitt,
|
||||
ftime = ftime
|
||||
ftime = ftime,
|
||||
workout = workouts,
|
||||
)
|
||||
)
|
||||
|
||||
@@ -2978,6 +2980,7 @@ def interactive_otwcpchart(powerdf,promember=0,rowername="",r=None,cpfit='data')
|
||||
('Duration ','@ftime'),
|
||||
('Power (W)','@CP{int}'),
|
||||
('Power (W) upper','@CPmax{int}'),
|
||||
('Workout','@workout'),
|
||||
])
|
||||
|
||||
hover.mode = 'mouse'
|
||||
|
||||
@@ -521,10 +521,11 @@ def cpdata(workouts, options):
|
||||
|
||||
|
||||
ids = [w.id for w in workouts]
|
||||
delta, cpvalue, avgpower = dataprep.fetchcp_new(r,workouts)
|
||||
delta, cpvalue, avgpower,workouts = dataprep.fetchcp_new(r,workouts)
|
||||
powerdf = pd.DataFrame({
|
||||
'Delta':delta,
|
||||
'CP':cpvalue,
|
||||
'workout':workouts,
|
||||
})
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user