Datasets and graphics served on the web using Vega-Lite.
Uses Python3, Flask, Vega-Lite, CouchDB server, CouchDB2 (Python module), Marko, emoji, jsonschema, Bootstrap, jQuery, DataTables.
Vega-Lite is a JavaScript library implementing a grammar of interactive graphics, provided by the University of Washington Interactive Data Lab (UW IDL).
For an example of how to use the API to update dataset contents, see example_dataset_update.py
-
Download and unpack the zipped codebase from https://github.com/pekrau/DataGraphics. The source code directory is called
{SOURCE}
in the following. -
Set up your Python3 environment, e.g. using virtualenv, for the
{SOURCE}
directory. -
Install the required Python3 third-party packages (Flask, etc) using
pip install -r requirements.txt'
in the{SOURCE}
directory. -
Create your JSON file
settings.json
in either the directory{SOURCE}/site
or{SOURCE}/datagraphics
by making a copy of{SOURCE}/site/settings_template.json
. Edit as appropriate for your site.For security, the
settings.json
should be readable only for the Linux account that runs the Flask server process.The
settings.json
file may contain an entryADMIN_USER
which will create an admin user if it doesn't exist. See thesettings_template.json
file for how it should look. The password for this user ought to be changed as soon as it has been created, for security.If your email server is not the simple
localhost
with no password, then you need to set those variables. See the file{SOURCE}/datagraphics/config.py
for all email-related settings variables. -
Set up the CouchDB database that your app will use, and add the name of it, any required username and password for it, in your
settings.json
file. -
Include the
{SOURCE}
directory in the Python path. This can be done in different ways. The simplest is to set it in the shell (e.g. in your .bashrc file):$ cd {SOURCE} $ export PYTHONPATH=$PWD:$PYTHONPATH
-
You mays use the command-line interface to create user accounts. (See point 4 above for how to create an admin user in a different way.) This will also automatically load the index definitions to the CouchDB server, if not already done.
$ python cli.py -A
-
Run the Flask app in development mode as usual. This will automatically load the index definitons to the CouchDB server, if not already done. If the
ADMIN_USER
entry has been defined properly in thesettings.json
file, it will be created.$ python app.py
-
For running the Flask app in production mode, see the information in the Flask manual and/or the Apache, nginx, or whichever outward-facing web server you are using.
docker-compose
, curl
, and sed
are needed.
- Create a settings file:
cp site/settings_template.json datagraphics/settings.json
- Change the host to
db
:sed -i 's/127.0.0.1:5984/db:5984/' datagraphics/settings.json
- Start the database:
docker-compose up db
- Create the database
datagraphics
:curl -u 'couchdb_db_account:couchdb_db_account_pwd' -X PUT http://localhost:5984/datagraphics
- Stop the database:
ctrl-c
ordocker-compose stop
- Start the full system:
docker-compose up
The development system can be accessed at: http://127.0.0.1:5005/
Port numbers on localhost can be changed in docker-compose.yml
, e.g.:
ports:
- 127.0.0.1:5000:5005
will allow you to access port 5005 in the container at port 5000 on localhost (127.0.0.1).