A demo of how to run Vega with a database. This is a fork of this project by @heavyairship, which is a fork of another project by @domoritz.
The primary Scalable Vega library component to be used in your application.
An interactive web demo of Scalable Vega components with examples of updating data and chart variables.
The middleware server required for running the Scalable Vega code and interacting with the user chosen database.
- Install and start PostgreSQL.
- Create a PostgreSQL database named
scalable_vega
, e.g.,createdb scalable_vega
. You don't need to do anything if you want to use DuckDB.
- Run
git clone [email protected]:leibatt/scalable-vega.git
. - Run
yarn --frozen-lockfile
andyarn build
to install scalable-vega library dependencies. - For using prepopulated database in demo, look at additional notes.
- Run
yarn build:server
to install scalable-vega server dependencies. - Run
yarn start:server_pg
to start the application server with postgres, for DuckDB runyarn start:server_duck
- All the config information for the databases and server (including user, password and ports to be used) is currently stored in the
./packages/server/duck_db.js
/./packages/server/postgres_db.js
files and can be customized.
- Make sure you have the middleware server running.
- In another terminal window, run
cd /path/to/dev/repos/scalable-vega
. - Run
yarn build:app
to build dependencies for the demo/application UI. - Run
yarn start:app
to start the web server. - Open a browser tab to localhost:1234.
- Upload the cars dataset from
./sample_data/data/cars.json
to the data input or click on theUpload Demo Data
button. - After uploading a dataset to database, upload a cars vega spec from
./sample_data/data/specs/specs/
to the specs inputor click on theShow me a Demo Spec
button and see the visualization.
- Again make sure you have the middleware server running.
- In another terminal window, run
cd /path/to/dev/repos/scalable-vega
. - The Unit Tests assume a prepopulated database, either do so by uploading data using the web demo or use the provided database (look at additional notes).
- For running the unit tests:
- For PostgreSQL,
yarn test transform_pg
- For DuckDB,
yarn test transform_duckdb
- For PostgreSQL,
- Prepopulated Database, We have provided prepopulated databases and scripts for PostgreSQL and DuckDB in
./packages/server/database
- For PostgreSQL, use a command like
psql dbname < infile
. For example,psql postgresql://postgres@localhost/scalable_vega < ./packages/server/database/scalable_vega.sql
- For DuckDB you can run
yarn start:duckdb-sample
which will populate a duckdb database file with 5 tables. You can customize the name of the db file being used by making changes in./packages/server/server.js
and./packages/server/database/duckdb_insertion.js
- For PostgreSQL, use a command like
- If you face
Cannot find name 'expect'
type error while running tests- Run
yarn add @types/jest -D
- Run