Skip to content

serebrov/flask-graphs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple python+flask API demo and d3/c3 data visualization.

Clone and do the setup:

mkvirtualenv flask-graphs
pip install -r requirements.txt

Run an app:

python application.py

Open API app: http://localhost:5000/static/index.html.

Or access API directly:

When application is started, it generates 10000 test data records. Under the hood it uses super-simple in-memory database to store data, so if you re-start an app the data is lost. To add more data - run python generator.py or POST data to /data endpoint:

curl -H "Content-Type: application/json" --data '[{
    "player": "Jack",
    "floor": "Ground",
    "position": {
        "x": 5,
        "y": 7
    },
    "ts": 1420070450
}]' http://localhost:5000/data

Sample data describes a game where we have some stats about players:

  • player - player name
  • floor - the floor player is on now (Underground, Ground, etc)
  • position - current x/y player's position
  • ts - current timestamp

Frontend is a pure html / js application. It queries data via API and then displays a d3 line chart (based on this example) and a c3-based line chart. Chars show count of players for each day.

Also frontend page displays heatmaps of visit count for each X,Y coordinate of each floor. Heatmap is based on this example. If you hover a heatmap cell the tooltip will show X,Y and count of visits.

The frontend page looks like this:

screenshot

About

Simple python+flask API demo and d3/c3 data visualization

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published