Facebook Pixel

NodeJS and MongoDB using socket.io Integration Template

This example shows how to run AnyChart library with NodeJS and MongoDB using socket.io.
View on GitHub


To use this sample you must have:

MongoDB installed and running, if not please checkout MongoDb installation guide. To check your MongoDB installation, run following command in command line:

$ mongod -version
db version v3.0.12 # sample output

To check MongoDB is running, type:

$ service mongod status
mongod start/running, process 9559 # sample output


$ ps -ef | grep mongod | grep -v grep
mongodb   1085     1  0 09:51 ?        00:00:52 /usr/bin/mongod --config /etc/mongod.conf # sample output

npm package manager, if not please visit official npm site. To check your npm installation, run following command in command line:

$ npm -v
1.3.10 # sample output

To start this example run commands listed below.

Clone the repository from github.com to your workspace folder:

$ git clone git@github.com:anychart-integrations/nodejs-socket-io-mongodb-template

Navigate to the repository folder:

$ cd nodejs-socket-io-mongodb-template

Install dependencies

npm install

install socket.io

npm install --save socket.io

Set up MongoDB:

$ mongo < database_backup.js

Start application:

$ node app.js

Open browser at http://localhost:3000/

Now you can see chart updating every 2 seconds, open another console and update MongoDB data:

$ mongo < database_update.js

Chart on the page will update automatically with new data


Your workspace should look like:

        development.js  # project settings for development
        pord.js         # project settings for production
        test.js         # project settings for testing
        Fruit.js        # data model
            style.css   # css styles
        index.js        # main route
        static.js       # static files route
        index.ejs       # template for main content
    app.js              # main js file
    database_backup.js  # backup for MongoDB
    database_update.js  # script for update MongoDB data
    package.json        # npm project settings


Further Learning


AnyChart NodeJS/Socket.io/MongoDB integration sample includes two parts:

  • Code of the integration sample that allows to use Javascript library (in this case, AnyChart) with NodeJS, Socket.io framework and MongoDB database. You can use, edit, modify it, use it with other Javascript libraries without any restrictions. It is released under Apache 2.0 License.
  • AnyChart JavaScript library. It is released under Commercial license. You can test this plugin with the trial version of AnyChart. Our trial version is not limited by time and doesn't contain any feature limitations. Check details here.

If you have any questions regarding licensing - please contact us. sales@anychart.com