I made a web application that graphs the life log recorded on Google Home like a Gantt chart.

I made a web application that graphs the life log like a Gantt chart

_People, people, people, people, people, people, people, people, people > LIFE LOG GRAPH GENERATOR <  ̄Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y ̄

Rough explanation

From the life log data in which `date and time` and` contents` are described. .. .. (Folded.)
October 15, 2019 at 11:24PM bedtime
October 16, 2019 at 06:03AM Get up
October 16, 2019 at 07:08AM going out
October 16, 2019 at 08:17AM development started
October 16, 2019 at 10:49AM development finished
October 16, 2019 at 12:30PM Return home
October 16, 2019 at 12:59PM Start reading
October 16, 2019 at 04:32PM Finish reading
October 16, 2019 at 10:31PM go to bed
October 17, 2019 at 06:46AM get up
October 17, 2019 at 07:29AM going out
October 17, 2019 at 08:27AM development started
October 17, 2019 at 12:48PM development finished
October 17, 2019 at 01:48PM Return home
October 17, 2019 at 02:35PM TV started
October 17, 2019 at 04:54PM TV quit

It is a web application that creates such an interactive graph. output

I'll move it!

demo

What are you happy about?

This is expected.

-** Because you can visualize your own life rhythm **, it will be an opportunity to change your life rhythm. --Just copy and paste the recorded ** life log ** and it will be graphed. ――Because you can see your actions like a ** Gantt chart ** instead of a pie chart, it is easy to compare different days.

In the first place, do you have such a moyamoya?

――Not good enough ** I don't understand my lifestyle (rhythm) **. ――It's a shame to record your actions in the life log app by ** manually **. --In the life log application, it is often represented by a ** pie chart **, but I would like it to be represented like a Gantt chart.

** This app will solve it. ** **

Precautions you should know

――This web application was made by me as a hobby for IT, who is from the Faculty of Earth Sciences and currently works for a mechanical company. Therefore, it seems that there are bugs and technical shortages. I hope you will try it after considering that. ――It's the first web application developed, and it's a complete trial for me, so I'm currently running it with the free plan of Heroku. Therefore, it may be affected by 30-minute sleep and Dyno limit. Please forgive me there (crying)

reference

What are you doing internally?

It is operated by python + Flask + Plotly + Heroku.

Roughly speaking

  1. Using Flask, display ʻindex.html where the input form is installed with / `.
  2. When the life log data is entered in the input form and the Create Graph button is pressed, format the data into csv format and create a Plotly instance of the Gantt chart.
  3. Display the graph.html with the createdPlotly instance embedded in / graph.
Dependency environment (folded)

requirement.txt


python==3.7.4
Flask==1.1.1
requests==2.22.0
gunicorn==19.9.0
pandas==0.25.1
plotly==4.1.1
Rough source code (folded)

app.py


import os
import re
import pandas as pd
from io import StringIO
from pathlib import Path
from datetime import datetime, timedelta
from plotly import figure_factory as pff
from plotly import offline
from flask import Flask, request, render_template


app = Flask(__name__)


#Gantt chart depiction main processing
def main(Data entered in the form):
  
Omitted because the code is too long and spaghetti

return plotly instance


#Format the data entered in the form into csv format.
def convert_input_data_to_csv(input_data):
    temp_data = re.sub(r",", "", input_data)
    conv_data = re.sub(r"(.+([AP]M|\d\d:\d\d))(\s+?)(\S+)", r"\1,\4", temp_data)

    return conv_data


#Render the main page.
@app.route("/", methods=["GET", 'POST'])
def render_main_html():
    return render_template("index.html")


#Render the setting page.
@app.route("/setting", methods=["GET", 'POST'])
def render_setting_html():
    return render_template("setting.html")


#render the graph page.
#The main function returns a plotly instance and embeds it in html.
@app.route("/graph", methods=["GET", 'POST'])
def render_graph_at_html():
    if request.method == 'GET':
        res = request.args.get('data')
    elif request.method == 'POST':
        res = request.form['data']
    else:
        res = None

    res_conv = convert_input_data_to_csv(res)

    df = pd.read_csv(StringIO(res_conv), sep=",", header=None).set_index(0)
    df.index = df.index.map(pd.to_datetime)

    return render_template("graph.html", fig=main(df))


if __name__ == '__main__':
    app.run(debug=False, host='0.0.0.0', port=int(os.environ.get('PORT', 5000)))

Introducing my operation method

Lifelog recording processing flow that makes full use of civilization's interests

I link Google Home + IFTTT + Google Spread Sheets and take a life log by voice.

flow

Then, the data recorded in the Spread Sheets is copied and pasted and graphed. (The linking method is explained in LIFE LOG GRAPH GENERATOR setting page.)

Finally

I found it very useful to visualize my life rhythm on a graph and look back.

First of all, ** I think it's okay to just look at the graph and grin **. It's so much fun to look at myself that I don't know, such as "Did you drink for 8 hours this day!" Or "Sleep time varies widely". I think this ** feeling of fun is a very important factor that leads to the habituation of life logs **.

And as I continue to grin, I naturally notice my own behavioral habits.

Do you take improvement action from that awareness? Or do you wait? Let's think about that later! If you can notice it, you can do anything else. (suitable)

I hope that this web app will give many people a chance to look at their lifelog graphs and grin, and to develop their awareness and actions in the future. think.

Thank you for reading until the end.

Recommended Posts

I made a web application that graphs the life log recorded on Google Home like a Gantt chart.
I made a WEB application with Django
I made a web application that converts photos into Van Gogh's style
I made a web application in Python that converts Markdown to HTML
I made a web application that maps IT event information with Vue and Flask
I made a calendar that automatically updates the distribution schedule of Vtuber (Google Calendar edition)
I made an Android application that displays Google Map
I made a VGG16 model using TensorFlow (on the way)
I made a neural network generator that runs on FPGA
A story that I had a hard time trying to create an "app that converts images like paintings" with the first web application
Note that I was addicted to accessing the DB with Python's mysql.connector using a web application.
Life game with Python [I made it] (on the terminal & Tkinter)
I made a program that solves the spot the difference in seconds
I made a slack bot that notifies me of the temperature
I made a scaffolding tool for the Python web framework Bottle
I made a program that automatically calculates the zodiac with tkinter
[Python] I analyzed the diary of a first-year member of society and made a positive / negative judgment on the life of a member of society.
[Python] I made a bot that tells me the current temperature when I enter a place name on LINE
Zura made like a life game
I made a calendar that automatically updates the distribution schedule of Vtuber
I made a kitchen timer to be displayed on the status bar!
The story of developing a web application that automatically generates catchphrases [MeCab]
[Python] I made a utility that can access dict type like a path
I made a Chrome extension that displays a graph on an AMeDAS page
I made a simple timer that can be started from the terminal
I made a library konoha that switches the tokenizer to a nice feeling
Until you publish (deploy) a web application made with bottle on Heroku
[Python] I made a web scraping code that automatically acquires the news title and URL of Nikkei Inc.
I made AI patroll the net and created a gadget ranking Web service that is updated once a week