Private
Public Access
1
0

chart fixes

This commit is contained in:
Sander Roosendaal
2020-11-24 19:34:45 +01:00
parent 8f53fa7d26
commit 20602c6644

View File

@@ -1624,12 +1624,14 @@ def fitnessfit_chart(workouts,user,workoutmode='water',startdate=None,
df.sort_values(['date'],inplace=True) df.sort_values(['date'],inplace=True)
#df = df.fillna(0)
df['testdup'] = df['testpower'].shift(1) df['testdup'] = df['testpower'].shift(1)
df['testpower'] = df.apply(lambda x: np.nan if abs(x['testpower'] - x['testdup']) < 4 \ df['testpower'] = df.apply(lambda x: np.nan if abs(x['testpower'] - x['testdup']) < 4 \
else x['testpower'],axis=1) else x['testpower'],axis=1)
#df = df.fillna(-100)
#print(df)
source = ColumnDataSource( source = ColumnDataSource(
data = dict( data = dict(
@@ -1644,6 +1646,7 @@ def fitnessfit_chart(workouts,user,workoutmode='water',startdate=None,
plot = Figure(tools=TOOLS,x_axis_type='datetime', plot = Figure(tools=TOOLS,x_axis_type='datetime',
plot_width=900, plot_width=900,
toolbar_location="above", toolbar_location="above",
@@ -1700,7 +1703,7 @@ def fitnessfit_chart(workouts,user,workoutmode='water',startdate=None,
plot.xaxis.major_label_orientation = pi/4 plot.xaxis.major_label_orientation = pi/4
plot.sizing_mode = 'stretch_both' plot.sizing_mode = 'stretch_both'
plot.y_range = Range1d(0,1.5*max(testpower)) #plot.y_range = Range1d(0,1.5*max(df['testpower']))
startdate = datetime.datetime.combine(startdate,datetime.datetime.min.time()) startdate = datetime.datetime.combine(startdate,datetime.datetime.min.time())
enddate = datetime.datetime.combine(enddate,datetime.datetime.min.time()) enddate = datetime.datetime.combine(enddate,datetime.datetime.min.time())
@@ -1718,13 +1721,14 @@ def fitnessfit_chart(workouts,user,workoutmode='water',startdate=None,
try: try:
script,div = components(plot) script,div = components(plot)
except: except Exception as e:
df.dropna(inplace=True,axis=0,how='any') df.dropna(inplace=True,axis=0,how='any')
return ( return (
'', '',
'Something went wrong withthe chart ({nrworkouts} workouts, {nrdata} datapoints)'.format( 'Something went wrong with the chart ({nrworkouts} workouts, {nrdata} datapoints, error {e})'.format(
nrworkouts = workouts.count(), nrworkouts = workouts.count(),
nrdata = len(df), nrdata = len(df),
e = e,
) )
) )