Original Source Here
Track & Visualize
The steps will be:
- Set up the tracking script
- Set up the visualization
- Wrap the code in a Streamlit app
1. The tracking script
Let’s begin by writing the script to track your focus:
Let’s unpack what is happening here:
- First we write a function called
trackFocus()which simply tracks an interval of time separated by a simple input from the user (like hitting return)
- Then we call the
calculatefocustime()function which returns the total amount of time tracked on a given day
- Finally, we call the
logFocus()function which logs the timestamps of the beginning and ending of a session
Now that we have our tracker, let’s write a simple visualization to look at our daily focused time.
2. Visualizing focus time
To visualize focus time we will need two functions, one for creating a dataframe to store our data properly, and another for the plot.
The code has two main parts:
- Creating the dataframe with the
- Plotting the focus using the
plotlylibrary in the
The cool thing about this is that it gives you an idea of how much time you spend actually concentrated on activities, and how that varies in time.
For me the insights are helpful, because they give me an overview of my consistency and my overall performance in terms of the time spent doing productive work.
3. Wrapping things up in a Streamlit app
Now, to finish things off, let’s make a simple dashboard app with Streamlit to be able to visualize our data anytime with just one simple command from the terminal.
Now, in the terminal we run:
streamlit run app.py
Trending AI/ML Article Identified & Digested via Granola by Ramsey Elbasheer; a Machine-Driven RSS Bot