Visualizing Your Data With MongoDB Charts
Tags: datavisualization, mongodb, nosql, airbnb
Published: 2019-02-10 19:16:15

---
title: Visualizing Your Data With MongoDB Charts
published: true
tags: Data Visualization,MongoDB,NoSQL,Airbnb
canonical_url: https://www.kenwalger.com/blog/nosql/mongodb/visualizing-data-mongodb-charts/
---

Having data stored in a database is practically a given for today’s businesses. Customer information, order history, product pricing, IoT sensor data, and much more is being recorded for future use. However, just having the data stored isn’t enough to form a competitive market advantage. We must be able to analyze the data as well. There are many options to do so and in a variety of ways. If you have data that needs to be visually analyzed in MongoDB, MongoDB [Charts](https://www.mongodb.com/products/charts) is a terrific option.

Prior to MongoDB Charts, there were really three ways to visualize your MongoDB Data.

1. Leverage the [MongoDB Business Intelligence (BI) Connector](https://www.mongodb.com/download-center/bi-connector) in conjunction with third-party BI tools,
2. Perform Extract-Transform-Load (ETL) operations and leverage third-party tools, or
3. Write custom code and use charting libraries such as D3.js or Bokeh.

#### MongoDB Charts Benefits

MongoDB Charts, currently in Beta, provides an easy way to visualize your data living in MongoDB. You don’t need to move your data to a different repository, write your own code, or purchase third-party tools. MongoDB Charts knows and understands the richness of the Document Data Model and allows for easy data visualization.

Further, MongoDB Charts allows for a secure way to create and share visualization dashboards with everyone, or just targeted team members. Similarly, the data source being used behind the scenes can be shared securely as well. For example, data for the Sales Department doesn’t have to be made available to Marketing unless needed. Very powerful and follows MongoDB’s design of security being a top priority.

After [downloading the MongoDB Charts](https://www.mongodb.com/download-center/charts) Docker image and following the [installation instructions](https://docs.mongodb.com/charts/master/installation/), we’re able to connect to a data source stored in MongoDB Atlas and start making visualization dashboards. Once connected to the MongoDB Charts server, there are three steps we need to take:

1. Add a data source
2. Create a dashboard
3. Create our charts

### Analyzing Airbnb Data with MongoDB Charts

I have set up a database with some Airbnb data from various cities. We’ll be exploring the dataset from Seattle, WA here, but feel free to explore others on your own. We need to get the connection string from the Atlas Cluster that has our data and connect to it in Charts.

[  
 ![Get URI From MongoDB Atlas for MongoDB Charts](https://i1.wp.com/webassets.mongodb.com/_com_assets/cms/atlas-URI-6k09mb3bg3.gif?w=840&ssl=1)  
](https://webassets.mongodb.com/_com_assets/cms/atlas-URI-6k09mb3bg3.gif)<figcaption>Get URI from MongoDB Atlas</figcaption>

#### Add a Data Source

With our MongoDB Charts server running on `localhost:80`, we can log in and head to the _Data Sources_ tab. We use the URI from Atlas (`mongodb+srv://airbnbdemo:airbnb@airbnb-rgl39.mongodb.net/test?retryWrites=true`) and select _Connect_. We’re next asked which data source we want to use from that cluster, I’ll select the **seattleListingAndReviews** from the `airbnb` database for this example. For permissions, I just want to keep everything private so I’ll accept the defaults and select _Publish Data Source_. Once published I can add an alias to the data source. I’ll call it `Airbnb Seattle`.

> Note: The URI above contains a sample URI. You should connect to your own Atlas Cluster and use an authorized username and password.

#### Create a Dashboard

Next up is to create an actual dashboard to house our visualizations. In the _Dashboards_ section choose **New Dashboard** and give it a name and description, like **Ken’s Airbnb Dashboard**. This will take me to where I can add charts to my dashboard.

#### Create a Chart

After clicking on the _Add Chart_ button we can start building our visualization. We’ll want to choose the `Airbnb Seattle` data source from the drop-down. MongoDB Charts automatically determines which fields are available for exploration. For this exercise, I’d like to see which neighborhoods in Seattle have the most Airbnb properties and split them by property type. We’ll use the Stacked Bar chart for the type.

1. 
  1. For the X-Axis then, we’ll want the `id` field, aggregated by count.

[  
 ![Assign X-Axis value in MongoDB Charts](https://i1.wp.com/webassets.mongodb.com/_com_assets/cms/x-axis-value-cz2tkvt97r.gif?w=840&ssl=1)  
](https://webassets.mongodb.com/_com_assets/cms/x-axis-value-cz2tkvt97r.gif)<figcaption>Assign X-Axis value to a MongoDB Chart</figcaption>

1. 
  1. Along the Y-Axis we’ll look at the address and the suburb. Notice that `address` is a subdocument here and that MongoDB Charts natively knows how to handle this type of data. I’d like to sort the `suburb` by aggregated value, in descending order, and limit our results to the top 20 suburbs.

[  
 ![Assign Y-Axis value to a Stacked Bar in MongoDB Charts](https://i1.wp.com/webassets.mongodb.com/_com_assets/cms/y-axis-value-h1llqzam8w.gif?w=840&ssl=1)  
](https://webassets.mongodb.com/_com_assets/cms/y-axis-value-h1llqzam8w.gif)<figcaption>Assign Y-Axis value to a Stacked Bar chart</figcaption>

1. 
  1. Let’s add the `property_type` field as our series

[  
 ![Assign a Series value to a Stacked Bar chart in MongoDB Charts](https://i1.wp.com/webassets.mongodb.com/_com_assets/cms/series-value-b1gprdumq6.gif?w=840&ssl=1)  
](https://webassets.mongodb.com/_com_assets/cms/series-value-b1gprdumq6.gif)<figcaption>Assign a Series value to a Stacked Bar chart</figcaption>

Now we can name our chart, _Properties by Location_ and save it. We’re then taken back to our dashboard where we can add other visualizations for further exploration.

Have a look at this short video to see some other visualizations being created from this same data source.

<iframe type="text/html" width="840" height="473" src="https://www.youtube.com/embed/c7gIXDYDrNU?version=3&amp;rel=1&amp;fs=1&amp;autohide=2&amp;showsearch=0&amp;showinfo=1&amp;iv_load_policy=1&amp;wmode=transparent" allowfullscreen="true" style="border:0;"></iframe>

## Conclusion

MongoDB Charts is an excellent new tool to visually explore your data. It has some great features for specific use cases, such as:

- Ad hoc analysis of your data
- Natively understands the benefits of the Document Data Model
- Collaboration on projects is easy with user-based sharing and permissions
- It’s intuitive enough for non-developers to use allowing for self-service data analysis

MongoDB Charts is the fastest way to build visualizations over your MongoDB data. I’d encourage you to [download it](https://www.mongodb.com/download-center/charts) and try it out today. Let me know what visualizations you come up with from the Airbnb dataset. I always enjoy seeing how people explore their data.

* * *

_This post was first published on the [MongoDB blog](https://dev.to/mongodb/visualizing-your-data-with-mongodb-charts-2eh4-temp-slug-3842302)_.

[![Facebook](https://i1.wp.com/www.kenwalger.com/blog/wp-content/plugins/social-media-feather/synved-social/image/social/regular/96x96/facebook.png?resize=48%2C48&ssl=1 "Share on Facebook")](http://www.facebook.com/sharer.php?u=https%3A%2F%2Fwww.kenwalger.com%2Fblog%2Fnosql%2Fmongodb%2Fvisualizing-data-mongodb-charts%2F&t=Visualizing%20Your%20Data%20With%20MongoDB%20Charts&s=100&p%5Burl%5D=https%3A%2F%2Fwww.kenwalger.com%2Fblog%2Fnosql%2Fmongodb%2Fvisualizing-data-mongodb-charts%2F&p%5Bimages%5D%5B0%5D=https%3A%2F%2Fwebassets.mongodb.com%2F_com_assets%2Fcms%2Fatlas-URI-6k09mb3bg3.gif&p%5Btitle%5D=Visualizing%20Your%20Data%20With%20MongoDB%20Charts "Share on Facebook")[![twitter](https://i0.wp.com/www.kenwalger.com/blog/wp-content/plugins/social-media-feather/synved-social/image/social/regular/96x96/twitter.png?resize=48%2C48&ssl=1 "Share on Twitter")](https://twitter.com/intent/tweet?url=https%3A%2F%2Fwww.kenwalger.com%2Fblog%2Fnosql%2Fmongodb%2Fvisualizing-data-mongodb-charts%2F&text=Hey%20check%20this%20out "Share on Twitter")[![google_plus](https://i1.wp.com/www.kenwalger.com/blog/wp-content/plugins/social-media-feather/synved-social/image/social/regular/96x96/google_plus.png?resize=48%2C48&ssl=1 "Share on Google+")](https://plus.google.com/share?url=https%3A%2F%2Fwww.kenwalger.com%2Fblog%2Fnosql%2Fmongodb%2Fvisualizing-data-mongodb-charts%2F "Share on Google+")[![reddit](https://i1.wp.com/www.kenwalger.com/blog/wp-content/plugins/social-media-feather/synved-social/image/social/regular/96x96/reddit.png?resize=48%2C48&ssl=1 "Share on Reddit")](http://www.reddit.com/submit?url=https%3A%2F%2Fwww.kenwalger.com%2Fblog%2Fnosql%2Fmongodb%2Fvisualizing-data-mongodb-charts%2F&title=Visualizing%20Your%20Data%20With%20MongoDB%20Charts "Share on Reddit")[![linkedin](https://i2.wp.com/www.kenwalger.com/blog/wp-content/plugins/social-media-feather/synved-social/image/social/regular/96x96/linkedin.png?resize=48%2C48&ssl=1 "Share on Linkedin")](http://www.linkedin.com/shareArticle?mini=true&url=https%3A%2F%2Fwww.kenwalger.com%2Fblog%2Fnosql%2Fmongodb%2Fvisualizing-data-mongodb-charts%2F&title=Visualizing%20Your%20Data%20With%20MongoDB%20Charts "Share on Linkedin")[![mail](https://i2.wp.com/www.kenwalger.com/blog/wp-content/plugins/social-media-feather/synved-social/image/social/regular/96x96/mail.png?resize=48%2C48&ssl=1 "Share by email")](mailto:?subject=Visualizing%20Your%20Data%20With%20MongoDB%20Charts&body=Hey%20check%20this%20out:%20https%3A%2F%2Fwww.kenwalger.com%2Fblog%2Fnosql%2Fmongodb%2Fvisualizing-data-mongodb-charts%2F "Share by email")

The post [Visualizing Your Data With MongoDB Charts](https://www.kenwalger.com/blog/nosql/mongodb/visualizing-data-mongodb-charts/) appeared first on [Blog of Ken W. Alger](https://www.kenwalger.com/blog).