How to create a Simple, Responsive, and Dynamic Dashboard in Web application
Tags: javascript, react, angular, dashboard
Published: 2019-04-17 10:36:03

---
title: How to create a Simple, Responsive, and Dynamic Dashboard in Web application
published: true
tags: JavaScript, React, Angular, Dashboard
canonical_url: https://blog.syncfusion.com/post/how-to-create-a-simple-responsive-and-dynamic-dashboard.aspx
---

Dashboards are very useful to track strategic data, key performance indicators, and important metrics from several data sources and visually present them. But designing a dashboard is a challenging job when you need features that let users place components, drag-and-drop, resize, and reorder. You’ll also need to present the dashboard with a responsive and adaptive layout, so it can be viewed at any resolution in any device without data loss.

Considering all these challenges, the Syncfusion [Dashboard Layout component](https://www.syncfusion.com/javascript-ui-controls/js-dashboard-layout) was implemented. It will create a dynamic dashboard quickly with the expected layout and allow you to think about only the data integration and projection.

You can place the component in a grid-structured layout at a desired place and design the layout by live-editing the panels with the help of reordering, drag and drop, resizing, add new, and removing functionalities.

Let’s try making a dashboard as shown in the following screenshot by using the Dashboard Layout component.

![A simple dashboard with Grid, Chart and Map components.](https://blog.syncfusion.com/wp-content/uploads/2019/04/DSL-2.png)_A simple dashboard with Grid, Chart and Map components._

You can get the demo sample from the GitHub repository: [How to create a dynamic and responsive dashboard ](https://github.com/SyncfusionExamples/How-to-create-a-dynamic-dashboard-with-responsive-and-adaptive-layout)

## Initialize the Dashboard Layout component

The list of dependencies required to render the Dashboard Layout component are as follows.

|– @syncfusion/ej2-layouts

|– @syncfusion/ej2-base

To use the Dashboard Layout component, we need to import it from the [**@syncfusion/ej2-layouts**](https://www.npmjs.com/package/@syncfusion/ej2-layouts)packages from the npm and append it to an element as shown in the following code example.

[index.ts]

```typescript
//importing DashboardLayout from ej2-layouts 
import { DashboardLayout } from '@syncfusion/ej2-layouts';
 
let dashboard: DashboardLayout = new DashboardLayout({}); 

dashboard.appendTo('#editLayout');
```

[index.html]

```html
<!-- dashboard layout element --> 

<div id="editLayout"></div>
```

## Creating panels

Panels are the building blocks of the Dashboard Layout component. It holds the data (components) to be visualized or presented. It has options to resize, reorder, or position a component in the desired manner. Configure the panels to place inside the dashboard as shown in the following code example.

[index.ts]

```typescript
let dashboard: DashboardLayout = new DashboardLayout({ 
//splits the entire width of the component into 6 equal columns. 
columns: 6, 
//defines the width/height ratio of each panel, here panel height will be 10/8 of its width value. 
cellAspectRatio: 100 / 80, 
//adding panel properties. 
panels: [
{'sizeX': 2, 'sizeY': 1, 'row': 0, 'col': 0 }, 
{'sizeX':2, 'sizeY': 1, 'row': 0, 'col': 2 }, 
{'sizeX': 2, 'sizeY': 1, 'row': 0, 'col': 4 }, 
{'sizeX': 3, 'sizeY': 2, 'row': 1, 'col': 0 }, 
{'sizeX': 3, 'sizeY': 2, 'row': 1, 'col': 3 }, 
{'sizeX': 3, 'sizeY': 2, 'row': 4, 'col': 0 }, 
{'sizeX': 3, 'sizeY': 2, 'row': 4, 'col': 3 },

]}); 

dashboard.appendTo('#editLayout');
```

In the above code block, **columns** and  **cellAspectRatio** properties defines the panel dimensions (height and width of each panel) to represent the number columns and panels placed in each row. In addition, you can turn on the panel resize option to enhance further live designing.

![Dashboard layout with empty panels](https://blog.syncfusion.com/wp-content/uploads/2019/04/empty_panels-with-expected-size-300x214.jpg)_Dashboard layout with empty panels_

## Adding components with header information to panels

In the Dashboard Layout components, Panels has options to define the header and content with complete customization. Header holds the supplemental data and also any action items like buttons or menu. The content of the panels can adopt any data or even data visualizing component such as chart or gauge or map. Refer to the following code example to add header and content to panels.

[index.ts]

```typescript
import { enableRipple } from '@syncfusion/ej2-base'; 

import { DashboardLayout } from '@syncfusion/ej2-layouts'; 

import { CircularGauge } from '@syncfusion/ej2-circulargauge'; 

import { gauge1, gauge2, gauge3 } from './gauge-component'; 

import { Grid } from '@syncfusion/ej2-grids'; 

// importing grid component. 
import { gridComponent } from './grid-component'; 

import { Maps} from '@syncfusion/ej2-maps'; 
// importing map component. 
import { mapsComponent } from './map-component'; 

import { Chart, Legend, Tooltip, ColumnSeries, Category, DataLabel } from '@syncfusion/ej2-charts'; 
// importing column chart. 
import { columnChartComponent } from './chart-component'; 

Chart.Inject(ColumnSeries, DataLabel, Category, Legend, Tooltip); 

enableRipple(true); 

// initializing DashboardLayout component. 

let dashboard: DashboardLayout = new DashboardLayout({

 columns: 5, 
cellSpacing: [25, 25], 
cellAspectRatio: 100 / 80, 

panels: [
{ 
'sizeX': 2, 'sizeY': 1, 'row': 0, 'col': 0, cssClass: 'card-template', content: '#card1' 
}, 
{ 
'sizeX': 2, 'sizeY': 1, 'row': 0, 'col': 2, cssClass: 'card-template', content: '#card2' 
}, 
{ 
'sizeX': 2, 'sizeY': 1, 'row': 0, 'col': 4, cssClass: 'card-template', content: '#card3' 
}, 
{ 
'sizeX': 3, 'sizeY': 2, 'row': 1, 'col': 0, header: '<div> Customer details</div>', content: '<div id="Grid"></div>' 
}, 
{ 
'sizeX': 3, 'sizeY': 2, 'row': 1, 'col': 3, header: '<div>Regional Map</div>', content: '<div id="map"></div>' 
}, 
{ 
'sizeX': 3, 'sizeY': 2, 'row': 4, 'col': 0, header: '<div>Sales in 2018 </div>', content: '<div id="colChart"></div>' 
}, 
{ 
'sizeX': 3, 'sizeY': 2, 'row': 4, 'col': 3, header: '<div> Sales Comparison </div>', content: '#card4' 
}
]}); 

dashboard.appendTo('#editLayout'); 

// initializing gauge components. 

let germany: CircularGauge = new CircularGauge(gauge1(), '#container1'); 

let usa: CircularGauge = new CircularGauge(gauge2(), '#container2'); 

let uk: CircularGauge = new CircularGauge(gauge3(), '#container3'); 

// initializing chart component. 

let chart: Chart = new Chart (columnChartComponent(),'#colChart'); 

// initializing grid component. 

let grid: Grid = new Grid(gridComponent(),'#Grid'); 

// intitalizing map component. 
let map: Maps = new Maps(mapsComponent(), "#map");
```

Here the first row of panel contains the HTML template cards. Then the grid component is initialized and rendered by obtaining the model values from the [grid-component.ts](https://github.com/SyncfusionExamples/How-to-create-a-dynamic-dashboard-with-responsive-and-adaptive-layout/blob/master/src/app/grid-component.ts) file.

![Grid contains customer details as records](https://blog.syncfusion.com/wp-content/uploads/2019/04/Grid.png)_Grid inside the panel_

Similarly, the other components, chart, maps, and gauge, are also imported from the [chart-component.ts](https://github.com/SyncfusionExamples/How-to-create-a-dynamic-dashboard-with-responsive-and-adaptive-layout/blob/master/src/app/chart-component.ts), [map-component.ts](https://github.com/SyncfusionExamples/How-to-create-a-dynamic-dashboard-with-responsive-and-adaptive-layout/blob/master/src/app/map-component.ts), and [gauge-component.ts](https://github.com/SyncfusionExamples/How-to-create-a-dynamic-dashboard-with-responsive-and-adaptive-layout/blob/master/src/app/gauge-component.ts) files, respectively.

![Shows the chart, map and gauge inside the panels](https://blog.syncfusion.com/wp-content/uploads/2019/04/ChartMapGuage.png)_Chart, Map and Circular gauge inside the panels_

Finally, you will get a simple dashboard with cards, grid, chart, gauges and map as shown in below screenshot with editable layout.

![A simple dashboard with DataGrid, Chart and Map components.](https://blog.syncfusion.com/wp-content/uploads/2019/04/DSL-2.png)_A simple dashboard with Grid, Chart and Map components_

Redesign the layout to a different structure by live editing the dashboard as like below.

![sales dashboard with live editing](https://blog.syncfusion.com/wp-content/uploads/2019/04/dashboardlayout.gif)_Dashboard with live editing_

## Conclusion

We hope this blog and the sample shared help you design a dynamic dashboard with grids, charts, and gauges using the Dashboard Layout component. The Dashboard Layout is also available in [Angular](https://ej2.syncfusion.com/home/angular.html), [React](https://ej2.syncfusion.com/home/react.html), [Vue](https://ej2.syncfusion.com/home/vue.html), [ASP.NET MVC](https://ej2.syncfusion.com/home/aspnetmvc.html) and [ASP.NET Core](https://ej2.syncfusion.com/home/aspnetcore.html) framework, so you can try out the sample based on your preferred one.

To learn more about the Dashboard Layout component, refer to the Syncfusion [online samples](https://ej2.syncfusion.com/demos/#/material/dashboard-layout/analytics-dashboard.html) and [documentation](https://ej2.syncfusion.com/documentation/dashboard-layout/getting-started). We look forward to you trying this component and providing your feedback through this [feedback portal](https://www.syncfusion.com/feedback/). You can also contact us through our [support forum](https://www.syncfusion.com/forums) or [Direct-Trac](https://www.syncfusion.com/support/directtrac/). We are happy to assist you!

The post [How to create a Simple, Responsive, and Dynamic Dashboard](https://blog.syncfusion.com/post/how-to-create-a-simple-responsive-and-dynamic-dashboard.aspx) appeared first on [Syncfusion Blogs](https://blog.syncfusion.com).