Navigation
This documentation refers to the MongoDB Charts beta service in MongoDB Atlas. Read the on-premises documentation to learn how to use the MongoDB Charts beta on site.

Setup and Import the Data

Estimated Time to Complete: 10 minutes

Prerequisites

The following items are required to complete this tutorial:

Download the Data

Download the example dataset from https://raw.githubusercontent.com/steveren/docs-assets/charts-tutorial/movieDetails.json. To download the documents, right-click on the URL and select Save Link As. This file contains the data you will import into the test.movieDetails collection of your Atlas cluster in the following step.

The movieDetails.json file is 1.4 MB and contains records for 2295 movies. The following is a sample document from the dataset:

{
     "_id" : ObjectId("5b107bec1d2952d0da904dd7"),
     "title" : "Titan A.E.",
     "year" : 2000,
     "rated" : "PG",
     "runtime" : 94,
     "countries" : [
             "USA"
     ],
     "genres" : [
             "Animation",
             "Action",
             "Adventure"
     ],
     "director" : "Don Bluth, Gary Goldman, Art Vitello",
     "writers" : [
             "Hans Bauer",
             "Randall McCormick",
             "Ben Edlund",
             "John August",
             "Joss Whedon"
     ],
     "actors" : [
             "Matt Damon",
             "Bill Pullman",
             "John Leguizamo",
             "Nathan Lane"
     ],
     "plot" : "A young man learns that he has to find a hidden Earth ship before an enemy alien species does in order to secure the survival of humanity.",
     "poster" : "http://ia.media-imdb.com/images/M/MV5BMjE0NTU0ODg4NV5BMl5BanBnXkFtZTcwNzY3MTQyMQ@@._V1_SX300.jpg",
     "imdb" : {
             "id" : "tt0120913",
             "rating" : 6.6,
             "votes" : 50875
     },
     "tomato" : {
             "meter" : 52,
             "image" : "rotten",
             "rating" : 5.7,
             "reviews" : 99,
             "fresh" : 51,
             "consensus" : "Great visuals, but the story feels like a cut-and-paste job of other sci-fi movies.",
             "userMeter" : 60,
             "userRating" : 3.2,
             "userReviews" : 69055
     },
     "metacritic" : 48,
     "awards" : {
             "wins" : 1,
             "nominations" : 7,
             "text" : "1 win & 7 nominations."
     },
     "type" : "movie"
}

Import the Data

Before you can use your dataset with Charts, you need to add it to a MongoDB collection. Use mongoimport to import the contents of that file into the test.movieDetails collection on your Atlas cluster.

mongoimport --host <atlasHostname> --ssl -u <username> -p <password> --authenticationDatabase admin \
--db test --collection movieDetails \
--drop --file <path/to/movieDetails.json>

Note

Refer to mongoimport for more information on using the import tool to add data to a MongoDB collection.

Add the Data Collection as a Data Source

Now that the data is in the desired collection, add the collection as a data source in MongoDB Charts. Adding a collection as a data source links the collection to Charts and allows us to create visualizations using that data.

  1. Launch Charts from the Atlas cluster which contains your imported data.

  2. Click the Data Sources tab.

  3. Click New Data Source.

  4. In the New Data Source dialog, select the Atlas Project which contains your imported data.

  5. Click Connect.

  6. Select the test.movieDetails collection.

  7. Click Set Permissions.

  8. Leave these options as default and click Publish Data Source.

    Note

    For details on data source permissions, see the Data Source Permissions page.

Next Steps

Now that you have established the data source in Charts, you can Create a New Dashboard which will hold the visualizations.