A simple repo to demo use of data from mongoDB to plot charts using D3.js with a rest api with express.js
NodeJS runs the server-side of the app. mongoDB is used for storing data to be displayed on graphs.
1. mongodb
2. express.js
3. d3.js
Make sure you initialize mongoDB before running.
-
Refer to Detailed installation guides to set up a mongoDB instance.
-
Via web console management create a database called d3nodeexpressmongoDB create user: mongouser password: d3Mongodb You will be using this in ./config/configmongo.js mongodb://mongouser:[email protected]:27017/d3nodeexpressmongoDB
-
Via web console management create a collection named populations
-
Via web console management ingest the sample data provided to seed 'populations' collection
-
Make sure mongodb can accept remote connections. http://www.mkyong.com/mongodb/mongodb-allow-remote-access/ If it is just for local dev use just comment out bind_ip AT YOUR OWN RISK
$ vim /etc/mongod.conf
# /etc/mongod.conf
# Listen to local, LAN and Public interfaces.
bind_ip = 127.0.0.1,your.mongoserver.lan.ip.address
/etc/init.d/mongodb restart
git clone https://github.com/yosiasz/d3-node-express-mongoDB.git
cd d3-node-express-mongoDB/
npm install -g nodemon
npm install
This will use node to launch the server (this will also seed your mongoDB using populations.json):
npm start
Leave the server running, and now you can access http://localhost:5000/.