Skip to main content

Heartbeat data plotter for matplotlib

Project description

This is just a tool for taking activity "heartbeats" (where something outputs what it is currently doing periodically) and making a few interesting charts and graphs with it using matplotlib.

This was originally written specifically for Wakatime data, but there's no reason it couldn't be applied to other things. For example, I am planning on using this with Discord rich presense activity exports.

Example usage (Wakapi):

from sqlite3 import connect
from datetime import datetime
from HeartbeatsData.heartbeats_data import HeartbeatData, show

print("Reading data")
conn = connect("../wakapi_db.db")
cur = conn.cursor()
hbs = cur.execute("SELECT project,time FROM heartbeats WHERE user_id='hopperelec'").fetchall()

print("Parsing data")
hb_data = HeartbeatData()
for hb in hbs:
    hb_data.add_hb(hb[0], datetime.strptime(hb[1][:19] + hb[1][-6:], "%Y-%m-%d %H:%M:%S%z"))

print("Producing legend")
hb_data.legend(ncol=2)

print("Plotting data")
# hb_data.plot_scatter()
hb_data.plot_durations(slider_kwargs={"default": 900})
# hb_data.plot_duration_counts(False, True, slider_kwargs={"default": 5400})

print("Displaying plot")
show()

Samples

(using the above code, all with the same data)

Scatter (time / day) graph Durations (time / day) graph Daily line duration counts (time / count) graph Weekly line duration counts (time and weekday / count) graph Daily heatmap duration counts (time / count) graph Weekly heatmap duration counts (time and weekday / count) graph

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

HeartbeatsData-1.0.0.tar.gz (17.4 kB view hashes)

Uploaded Source

Built Distribution

HeartbeatsData-1.0.0-py3-none-any.whl (17.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page