Click here to Skip to main content
15,881,248 members
Articles / Web Development / HTML

Simple Dashboard

Rate me:
Please Sign up or sign in to vote.
4.73/5 (42 votes)
6 Jul 2013CPOL7 min read 397.7K   43.5K   111   34
Simple dashboard utilizing an elegant HTML+CSS+JavaScript template from TechGYO and the Highcharts library.

Introduction

A dashboard is an easy to read, single-page graphical presentation of current status within an organization. With the increasing popularity of BI solutions and web applications as a delivery platform, there has been an increasing demand for easy to implement web portals that operate as functional dashboards.

A typical dashboard can be separated out into three functional layers, the dashboard UI layer, charting components or tabular representations of data and a data retrieval layer. The UI layer comprises the overall look & feel of the dashboard. It determines the structure of a dashboard in terms of header, footer and menu system components. It provides a subsystem of panels that can house charting components or tabular summaries of organizational data. The data retrieval layer is not unique to dashboards, it is an essential part of most non-trivial web applications and as is treated as out-of-scope for this article. We will focus on implementing the UI layer and a charting system that can be replicated for various types of dashboards.

The attached solution contains two projects. One project (HighchartsWebApp) demonstrates the use of the ASP.NET control to create the dashboard. It is a minimalistic demo for those of us desiring a mostly C# based dashboard solution. The second and primary project (HighChartsJavaScript) uses JavaScript to fully leverage capabilities of the charting component (Highcharts) that I selected for this demo. I have implemented both projects to provide alternate paths to our goal of creating a generic dashboard.

The UI layer as implemented is a combination of JavaScript, CSS and HTML that was designed by the people at TechGYO. I loved the simplicity of the design and decided to leverage it to create this Dashboard. My goal was to provide an example that could be used as a starting point. This project is targeted to beginners and has not been stress-tested / live-tested at the time of publication. I might use the feedback in the comments to provide future updates as time permits.

Please download the attached file (HighchartsWebFinal.zip), unzip and open the Visual Studio 2012 solution so you can refer to the code while reading the rest of this article.

You can activate the JavaScript version by right-clicking the project ‘HighChartsJavaScript’ within Solution Explorer and selecting ‘Set As StartUp Project’. This project implements both the UI and charting components using JavaScript.

You can alternately run the second project by right-clicking the ‘HigchartsWebApp‘ project within Solution Explorer and selecting ‘Set As StartUp Project’. This project differs in that the charting component is entirely wrapped within an ASP.NET control and all manipulation of the charts can be done using C# with no reliance on JavaScript. Once you have made your choice, press ‘F5’ to activate the demo.

VS2012 - Solution Explorer View

I have put in less effort into the HigchartsWebApp project as I expect future development to concentrate on developing the JavaScript version of the charting code. This version does use some C# code to retrieve and populate data but the charting controls are defined & executed entirely in JavaScript. If you would like to get more information on using a purely server-side implementation like the ‘HighchartsWebApp’ project, you can check the website for Highcharts.Net, an open source project (http://highcharts.codeplex.com/).

Dashboard - Operation

Dashboard - Initial View

The screenshot above shows an annotated view of the initial dashboard screen. Note, the last (green background) section has been intentionally left empty. Clicking on this section brings up the equivalent of a drill down/popup report (see next screenshot).

Dashboard - Popup

Note, the header changes to reflect a title for the drill down report. The Metro UI themed arrow appears to allow navigation back to the main dashboard.

Assuming you have the solution open in VS2012, the above information should be sufficient to guide most of you in getting the project to execute, you could even start modifying it for your individual requirements. For those wanting a deeper dive, let us now look into the code so we can get a clearer vision of its operation.

As mentioned earlier, the attached solution contains two projects, the discussion from this point on focuses on the JavaScript version (‘HighChartsJavaScript’). Our objective is to utilize a charting library like Highcharts to create a dashboard. Additionally, we would like to determine how we can dynamically integrate our data into the charts without having to hard-code it as part of the JavaScript code. Data retrieval in most cases is so much easier in C#. The ideal scenario would allows us to use C# code to retrieve data, pass it seamlessly to the JavaScript library for rendering into charts for our dashboard.

I have broken down this review into three parts matching the three functional layers discussed above. Part 1 deals with the setup of the dashboard. It examines the HTML, CSS and JavaScript code that enables the look, feel and animation of the dashboard UI. Part 2 will look into the JavaScript code that creates a chart. Part 3 will demonstrate how we can use C# to merge sample application data with the chart code to enable us to integrate our data with the Highcharts library.

Part 1: Dashboard

The dashboard code as previously mentioned is based on a free template released by the folks at TechGYO. The majority of the code is contained in the file ‘index.html’, the adjacent screen snippet shows a collapsed view of this file with highlights & labels calling out various functional areas within the code. Note, the code has been collapsed in Visual Studio to provide this bird’s-eye view.

Dashboard - Popup

If you examine the code that draws each dashboard panel (lines 112 – 125), you will notice that it consists of a hyperlink enclosing an empty div and not much else.

Dashboard - Popup

This is because all the work of populating the panel is done within JavaScript code blocks that we will discuss in ‘Part 2: Drawing the charts’. The hyperlinks themselves are mostly inert and used only in case of panel 6 (the green panel) to demo drilldown/popup functionality.

Part 2: Drawing the Charts

As mentioned in the previous section, each dashboard panel is initially empty and populated by individual JavaScript code blocks. The snippet below shows one such block alongside the chart rendered.

Panel 1 - Highcharts markup

This script defines a JavaScript object. Line 214 ensures that the object (Linechart) is placed inside Panel 1. Lines 245 – 257 define the series data being displayed on the chart. Note, Highchart objects are defined using JSON. If you are unfamiliar with JSON, you should look up one of the many tutorials available on the web. A good starting reference is the one at http://www.w3schools.com/json/.

Part 3: Merging Application Data with Chart Code

You may have realized that the example until this point is of limited utility as the data is hard-coded into the page. Most use case scenarios involve reading data from a data source and dynamically populating the chart. This section seeks to get you started on that path. In the interest of brevity and focus, I do not plan to cover how data is to be extracted from your data source. I assume you are able to write the code to read your application data. For what it’s worth, I have included some commented code that I used for my application. The item to note in the code below is that we are using some variables (arrays defined at the class-level) to store the values that will be the input for our chart.

Populating chart data on server

You can then bind your application data into JavaScript code using data-binding expressions.

Data-binding server-side expressions to markup

That completes this brief introduction to developing a dashboard. You can modify the JavaScript code to use any other JavaScript-based charting library. You are not limited to charts alone, the content of each dashboard panel can be pretty much anything that is valid within a web page. The simplicity of the template will hopefully ensure a short and gentle learning curve. Feel free to throw out ideas on where you would like to take this dashboard, perhaps we can explore those in a future update.

Dependencies

  1. Visual Studio 2012 (http://www.microsoft.com/visualstudio/eng/downloads)
  2. Highcharts Charting Library (http://www.highcharts.com/products/highcharts)
  3. Highcharts.Net (http://highcharts.codeplex.com/) – not affiliated with Highcharts Charting Library
  4. Metro UI Template by TechGYO.com (http://techgyo.com/index.php/free-metro-ui-html-template-by-techgyo/)

Dashboard Implementation Reference Websites

  1. The Geckoboard Blog (https://demo.geckoboard.com/dashboard/B6782E562794C2F2/)
  2. jSlate (https://github.com/rasmusbergpalm/jslate/graphs)
  3. D3 (https://github.com/mbostock/d3/wiki/Gallery)
  4. Vaadin Dashboard (https://vaadin.com/demo)

History

  • 04 July 2013 - Initial draft
  • 06 Oct 2014 - Added VS2010 version

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
United States United States
ASP.Net Developer
Seattle, WA

Comments and Discussions

 
QuestionA sample dashboard using VB.NET Pin
utchay21-Jan-19 1:52
utchay21-Jan-19 1:52 
GeneralDashboard Pin
Member 1384257424-May-18 1:27
Member 1384257424-May-18 1:27 
SuggestionContribution Dashboard Project Pin
Renatoch28-Apr-16 9:12
Renatoch28-Apr-16 9:12 
GeneralMy vote of 4 Pin
Abhishek Kumar Goswami29-Dec-15 23:01
professionalAbhishek Kumar Goswami29-Dec-15 23:01 
QuestionDrill Down Label and and tables Pin
Member 1216594924-Dec-15 1:54
Member 1216594924-Dec-15 1:54 
QuestionCommercial Use Pin
Member 939473825-Sep-15 7:13
Member 939473825-Sep-15 7:13 
AnswerRe: Commercial Use Pin
kannankeril25-Sep-15 19:41
kannankeril25-Sep-15 19:41 
GeneralRe: Commercial Use Pin
Member 939473828-Sep-15 6:00
Member 939473828-Sep-15 6:00 
GeneralCredible Pin
Member 1159624010-Apr-15 0:07
Member 1159624010-Apr-15 0:07 
Questionadding circular guage Pin
Member 1131300118-Mar-15 5:26
Member 1131300118-Mar-15 5:26 
QuestionWhat about realtime data? Pin
Win32nipuh26-Jan-15 22:19
professionalWin32nipuh26-Jan-15 22:19 
Great, thank you.

Is it possible to use these charts to display the realtime data?

For example:

I want to display 2 dynamic charts about CPU and Memory usage.
For it I can use WCF Rest service method which returns json data.
Javascript can call this method by timer tick.

Regards.
AnswerRe: What about realtime data? Pin
kannankeril27-Jan-15 21:33
kannankeril27-Jan-15 21:33 
QuestionMissing Pictures Pin
Member 1075072215-Dec-14 21:46
Member 1075072215-Dec-14 21:46 
AnswerRe: Missing Pictures Pin
kannankeril16-Dec-14 3:21
kannankeril16-Dec-14 3:21 
GeneralRe: Missing Pictures Pin
Eng Mohamed Nasr12-Oct-16 22:31
professionalEng Mohamed Nasr12-Oct-16 22:31 
QuestionHow to run it in Visual Studio 2010 Pin
Member 96171525-Oct-14 18:16
Member 96171525-Oct-14 18:16 
AnswerRe: How to run it in Visual Studio 2010 Pin
kannankeril6-Oct-14 17:10
kannankeril6-Oct-14 17:10 
AnswerRe: How to run it in Visual Studio 2010 Pin
kannankeril7-Oct-14 16:53
kannankeril7-Oct-14 16:53 
QuestionExcellent Pin
Member 1109101618-Sep-14 0:57
Member 1109101618-Sep-14 0:57 
QuestionOne Doubt Pin
jakss10-Sep-14 21:25
jakss10-Sep-14 21:25 
AnswerRe: One Doubt Pin
kannankeril11-Sep-14 18:03
kannankeril11-Sep-14 18:03 
BugMissing dowload file Pin
Member 1107320910-Sep-14 10:02
Member 1107320910-Sep-14 10:02 
GeneralRe: Missing dowload file Pin
kannankeril10-Sep-14 16:18
kannankeril10-Sep-14 16:18 
GeneralRe: Missing dowload file Pin
Member 1107320911-Sep-14 2:34
Member 1107320911-Sep-14 2:34 
GeneralRe: Missing dowload file Pin
kannankeril11-Sep-14 18:06
kannankeril11-Sep-14 18:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.