Add expected year distance chart.
This commit is contained in:
parent
2cd36b5e52
commit
e1c68a55b3
@ -13,8 +13,8 @@ LOG_FORMAT = "%(asctime)s %(levelname)s %(message)s"
|
||||
|
||||
UPDATE_INTERVAL = 60
|
||||
|
||||
logging.basicConfig(format=LOG_FORMAT, level=log_level, filename=LOG_FILE)
|
||||
# logging.basicConfig(format=LOG_FORMAT, level=log_level)
|
||||
# logging.basicConfig(format=LOG_FORMAT, level=log_level, filename=LOG_FILE)
|
||||
logging.basicConfig(format=LOG_FORMAT, level=log_level)
|
||||
log = logging.getLogger('bicycle-statistics')
|
||||
|
||||
def parse_args():
|
||||
|
@ -140,12 +140,12 @@ class Gpx2Html(object):
|
||||
'Average Speed', 'Month', 'km/h',
|
||||
os.path.join(self.outfolder, 'avg_spd.png'))
|
||||
|
||||
now = datetime.datetime.now()
|
||||
# Accumulated distance:
|
||||
accumulated_distance = dict()
|
||||
for year in self.tracks.years():
|
||||
acc_year_dist = list()
|
||||
start_date = datetime.datetime(year, 1, 1)
|
||||
now = datetime.datetime.now()
|
||||
end_date = datetime.datetime(year, 12, 31)
|
||||
if year == now.year:
|
||||
end_date = now
|
||||
@ -162,6 +162,25 @@ class Gpx2Html(object):
|
||||
"Accumulated Distance", 'Month', 'km',
|
||||
os.path.join(self.outfolder, 'acc_dist.png'))
|
||||
|
||||
# Expected year distance:
|
||||
start_date =datetime.datetime(now.year, 1, 1)
|
||||
end_date = now
|
||||
tracks = self.tracks.tracks(start_date, end_date)
|
||||
acc_year_dist = list()
|
||||
exp_year_dist = list()
|
||||
for date in generate_date_list(start_date, end_date):
|
||||
date_distance = get_distance_by_date(tracks, date)
|
||||
try:
|
||||
acc_year_dist.append(date_distance + acc_year_dist[-1])
|
||||
except IndexError:
|
||||
acc_year_dist.append(date_distance)
|
||||
expexted_distance = acc_year_dist[-1] / date.timetuple().tm_yday * 365
|
||||
exp_year_dist.append(expexted_distance)
|
||||
xyz = dict()
|
||||
xyz['driven'] = acc_year_dist
|
||||
xyz['expected'] = exp_year_dist
|
||||
plot_line_chart(xyz, MONTH_LABELS[:now.month], "Distance", 'Month',
|
||||
'km', os.path.join(self.outfolder, 'exp_dist.png'))
|
||||
|
||||
|
||||
end_date = datetime.datetime.today()
|
||||
@ -268,6 +287,7 @@ class Gpx2Html(object):
|
||||
handle.write('<p>\n')
|
||||
handle.write('<IMG SRC="{}" ALT="Distance">\n'.format('distance.png'))
|
||||
handle.write('<IMG SRC="{}" ALT="Distance">\n'.format('acc_dist.png'))
|
||||
handle.write('<IMG SRC="{}" ALT="Distance">\n'.format('exp_dist.png'))
|
||||
handle.write('<IMG SRC="{}" ALT="Distance">\n'.format('avg_spd.png'))
|
||||
handle.write('<IMG SRC="{}" ALT="Distance">\n'.format('last_14_days.png'))
|
||||
handle.write('</p>\n')
|
||||
|
Loading…
Reference in New Issue
Block a user