MITB Banner

Drag and Drop Visuals in your Interactive Dashboard – Gridster & D3.js

Share

gridsterAs part of my continued interactions with the open source stack, I came across a very nice library: Gridster.js. Gridster is a really cool and awesome JavaScript library that enables drag and drop as well as re-sizing features for your html placeholders (div’s).

One aspect of BI self-service modules is the flexibility for the user to define his own story line and the order in which the user wants to see the visuals. That got me thinking if gridster can help us out there.
We will be trying to build a drag and drop dashboard which allows user to rearrange the elements dynamically.

We will be taking the analytics dashboard that we built using D3.JS, DC.JS, Node JS and MongoDB and apply Gridster.js to it resulting in a dashboard in which we can rearrange the visuals on a grid without losing the interactive features like drill-down and filtering.

Our AIM:  Implement Gridster.js library in our interactive dashboard to enable rearrangement and re-sizing of visuals.

Steps to Success:

  1. Get your hands on the working dashboard.
  2. Insert the Gridster libraries into your html page.
  3. Enclose your div’s within Gridster list tags.
  4. Run your app and see if the functionality works.

Here’s how our finished dashboard will look like:

https://anmolkoul.files.wordpress.com/2015/07/gridpreview.gif

I strongly recommend going through the tutorial that guides you on creating an interactive dashboard before starting this tutorial. The source code for this tutorial can be found at this github repository. This code is complete in itself and utilizes the dashboard we built previously and implements the Gridster library into it.

Step 1: Get your Hands on the working dashboard

You can download the project folder from this repository at github. Download/Fork it and navigate to the gridster-D3 directory in your command prompt /shell and start the app by using npm start.

Step 2: Insert the Gridster libraries into your html page

We can set the base dimensions for the widgets. Think of base dimensions as the building block for the grids. You can set the width and height of your div’s in multiples of the base dimensions.
We define the margins for the widgets and you might notice a resize option which we have set to false. Yes, Gridster allows you to manually resize your grid elements. In this case we have svg charts generated by DC.js and i gave it a skip.

Step 3: Enclose your div’s within Gridster list tags

Gridster essentially divides your webpage into grids and columns. The data-row and data-col attribute enable you to place your div at a desired location on the grid.
The data-sizex and data-sizey are the attributes that define the size of the grid element that is to be created. Note that this is essentially builds on the base dimensions that we described earlier.

Step 4: Run your app

Go to the app folder, in this case gridster-D3 and execute npm start command.

Fire up you browser and go to localhost:8080 to view the dashboard. Drag and drop the elements to see the Gridster functionality.

This was a detailed overview for implementing Gridster on an interactive D3 based analytics dashboard.

Do post any question or comments in the comments section. I will be happy to discuss further.

For the complete post please visit: https://anmolkoul.wordpress.com/2015/07/06/drag-and-drop-visuals-in-your-interactive-dashboard-gridster-d3-js/

 

Share
Picture of Anmol Koul

Anmol Koul

Anmol has been working for nearly 4 years in the BI domain. He is working right now as a Senior-consultant in the BI program at Wincere Inc. He has worked across geographies and a number of clients in a consulting role. Recently he has shifted his focus to the open source stack and develops cutting edge visualization solutions using open source libraries. Apart from coding and consulting Anmol can be found listening to music or playing basketball. His twitter handle is @anmolkoul
Related Posts

CORPORATE TRAINING PROGRAMS ON GENERATIVE AI

Generative AI Skilling for Enterprises

Our customized corporate training program on Generative AI provides a unique opportunity to empower, retain, and advance your talent.

Upcoming Large format Conference

May 30 and 31, 2024 | 📍 Bangalore, India

Download the easiest way to
stay informed

Subscribe to The Belamy: Our Weekly Newsletter

Biggest AI stories, delivered to your inbox every week.

AI Courses & Careers

Become a Certified Generative AI Engineer

AI Forum for India

Our Discord Community for AI Ecosystem, In collaboration with NVIDIA. 

Flagship Events

Rising 2024 | DE&I in Tech Summit

April 4 and 5, 2024 | 📍 Hilton Convention Center, Manyata Tech Park, Bangalore

MachineCon GCC Summit 2024

June 28 2024 | 📍Bangalore, India

MachineCon USA 2024

26 July 2024 | 583 Park Avenue, New York

Cypher India 2024

September 25-27, 2024 | 📍Bangalore, India

Cypher USA 2024

Nov 21-22 2024 | 📍Santa Clara Convention Center, California, USA

Data Engineering Summit 2024

May 30 and 31, 2024 | 📍 Bangalore, India

Subscribe to Our Newsletter

The Belamy, our weekly Newsletter is a rage. Just enter your email below.