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)
|
cpfile = 'media/cpdata_{id}.parquet.gz'.format(id=workout.id)
|
||||||
try:
|
try:
|
||||||
df = pd.read_parquet(cpfile)
|
df = pd.read_parquet(cpfile)
|
||||||
|
df['workout'] = str(workout)
|
||||||
data.append(df)
|
data.append(df)
|
||||||
except OSError:
|
except OSError:
|
||||||
# CP data file doesn't exist yet. has to be created
|
# 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:
|
if len(data) == 0:
|
||||||
return pd.Series(),pd.Series(),0
|
return pd.Series(),pd.Series(),0,pd.Series()
|
||||||
if len(data)>1:
|
if len(data)>1:
|
||||||
df = pd.concat(data,axis=0)
|
df = pd.concat(data,axis=0)
|
||||||
|
|
||||||
@@ -1039,7 +1042,7 @@ def fetchcp_new(rower,workouts):
|
|||||||
|
|
||||||
df = df.sort_values(['delta']).reset_index()
|
df = df.sort_values(['delta']).reset_index()
|
||||||
|
|
||||||
return df['delta'],df['cp'],0
|
return df['delta'],df['cp'],0,df['workout']
|
||||||
|
|
||||||
def setcp(workout):
|
def setcp(workout):
|
||||||
strokesdf = getsmallrowdata_db(['power','workoutid','time'],ids = [workout.id])
|
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))
|
deltas = fitt.apply(lambda x: timedeltaconv(x))
|
||||||
ftime = niceformat(deltas)
|
ftime = niceformat(deltas)
|
||||||
|
workouts = powerdf['workout']
|
||||||
|
|
||||||
sourcecomplex = ColumnDataSource(
|
sourcecomplex = ColumnDataSource(
|
||||||
data = dict(
|
data = dict(
|
||||||
CP = fitpower,
|
CP = fitpower,
|
||||||
CPmax = ratio*fitpower,
|
CPmax = ratio*fitpower,
|
||||||
duration = fitt,
|
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'),
|
('Duration ','@ftime'),
|
||||||
('Power (W)','@CP{int}'),
|
('Power (W)','@CP{int}'),
|
||||||
('Power (W) upper','@CPmax{int}'),
|
('Power (W) upper','@CPmax{int}'),
|
||||||
|
('Workout','@workout'),
|
||||||
])
|
])
|
||||||
|
|
||||||
hover.mode = 'mouse'
|
hover.mode = 'mouse'
|
||||||
|
|||||||
@@ -521,10 +521,11 @@ def cpdata(workouts, options):
|
|||||||
|
|
||||||
|
|
||||||
ids = [w.id for w in workouts]
|
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({
|
powerdf = pd.DataFrame({
|
||||||
'Delta':delta,
|
'Delta':delta,
|
||||||
'CP':cpvalue,
|
'CP':cpvalue,
|
||||||
|
'workout':workouts,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user