The need for an insightful dashboard, giving a bird’s eye view to stakeholders, has always been a welcoming deal for any organisation.

However, creating one that looks appealing in a short span of time, without writing any of that front-end & back-end code, seems like a dream.

Imagine you have a collection of restaurants, servings a myriad of cuisines to please your palate, American, Turkish, Irish and many more spread across the state. Now, if you are asked to present a visual representation of your data stored in MongoDB, on a dashboard, answering the following questions:

A plausible solution that comes to us in general is :

Considering all these points, you finally propose an estimate & prepare yourself to code, but suddenly some additional features are thrown your way:

An instant reaction would be

Wouldn’t it be great if we could get a solution to all these statements with ZERO Code & lay down a beautiful

dashboard in just a few clicks.

I know you like the sound to it, so let’s get rolling.

Quickly hop on to MongoDB Atlas,sign-up if you haven’t & you will be logged on to a console which should look like below. Click on the charts option to the left of the screen.

MongoDB Atlas Console-Collection View

In most cases, you will have your own existing data-set. If not, don’t worry, use the below command to get access to a huge data-set to play with MongoDB Charts.

wget -q -O- https://raw.githubusercontent.com/mongodb/docs-assets/primer-dataset/primer-dataset.json | mongoimport — host vision01-shard-00–00-r55zf.gcp.mongodb.net:27017,vision01-shard-00–01-r55zf.gcp.mongodb.net:27017,vision01-shard-00–02-r55zf.gcp.mongodb.net:27017 — ssl — authenticationDatabase admin — username <YOUR-USERNAME> — password <YOUR-PASSWORD> — db <DATABASE-NAME> — collection <COLLECTON-NAME> — type json

This command uses a utility Wget 1.20 for windows, which you can download here, this will import the data-set directly to your MongoDB instance based on the connection string.

Let’s start with adding the above collection as the data source for our dashboard. I will be choosing the ‘restaurants’ collections.

Move on to the ‘Data Sources’ tab & click on ‘New Data Source’.

Once you have it in place, click on the ‘Dashboard’ tab to add your first chart, to display the total number of restaurants ‘situated in the Manhattan area’.

Chart Type as Text With Custom Filter

The favorite feature for me in MongoDB charts is the ability to write custom filters, so, let’s filter the restaurants that are located only in Manhattan.

{‘borough’:’Manhattan’}

Voila, we have our very first chart-representation in just under a minute.

On similar lines, we can prepare our second representation to depict the count of restaurants ‘serving pizza’ with a slight variation to our filter.

{‘cuisine’:’Pizza’}

Restaurants Serving Pizza From Our Collection

Simple isn’t ?

Hope you would have liked the warm-up, let’s…

It will take some interesting work to build the representation for ‘Ratings Of Restaurants In All Locations’.

Here in our collection, we have a set of ‘grades’ as A, B, C, P, Z & with each ‘grade’, there is ‘score ’associated. We need to group all these data points together based on all distinct locations available.

We will be using the $unwind aggregation concept here.

MongoDB charts also give you a bunch of customization options.

{
$and: [ { borough:{ $ne: 'Missing' }}, { 'grades.grade':{ $nin: ['Not Yet Graded'] }} ]
}

Chart Type As Column-Grouped To Represent Ratings Of Restaurants In All Locations

Let’s tackle one more interesting scenario to depict the ‘Top 15 Most Served Cuisines’ from our restaurant data-set.

However, we need only the top 15.

There you have it, one more beautiful chart in almost no time.

{ cuisine: { $nin: [‘Not Listed/Not Applicable’, ‘Other’] } }

Chart Type As Bar-Stacked To Represent Top 15 Most Served Cuisines

Time for something sweet.

Here I will create a quick donut-chart representing ‘Comparison Of Popular Food Itemsusing the below filter.

{cuisine:{$in:[‘Pizza’, ‘Hamburgers’, ‘Donuts’, ‘Hotdogs’]}}

Chart Type As Circular-Donut To Represent Comparison Of Popular Food Items Viz. Pizza, Hamburgers, Hotdogs

Customize The Dashboard Layout

MongoDB Charts also offers a quick drag customization option, which you can utilize to create the dashboard layout that suits your visual design the most.

Customize Dashboard With Simple Drag

Can you lock down dashboard, according to roles or permission?

Yes, definitely.

MongoDB Charts give you full flexibility to allow certain folks in your team to make changes to your dashboard & others can be granted a readers-only role.

Set up Dashboard permissions, following this simple documentation.

MongoDB Charts, open a whole new dimension for creating stunning dashboards, not only for developers but also for management & administration teams in the organization with simple configurations & no code in quickest time.

When I started on with MongoDB charts, there were not much resources to follow, apart from some official documentation & personal understanding. However, now, kudos to MongoDB team for this cool video.

Do explore more & expand with your awesome use cases.

Hope you enjoyed reading & learned something new.

Don't’ feel shy to appreciate with some claps.

See you soon.

Like to learn through efficient hacks? We might use your quirky mind in our team! Join us in making the next life-centric digital solutions

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store