visit
Analysis is one of the most critical steps in any project. A vast amount of various data and records actually contain more than you think — patterns and dependencies. By studying them, you can significantly improve your decision-making abilities and learn much more than just numbers — you can see trends and predict future tendencies. But for all this, you need a comprehensive analysis and a view from different angles.
For such thorough work, one way of analysis will not work; you need to use all methods of data processing and visualization. Therefore, the best and most irreplaceable assistant in such matters is .
Due to the use of different types of charts, heatmaps, and tables, dashboards allow you to visually compare metrics and show the extremes, the difference, and tendencies of changes in values in an easily perceived form. And all this is based on the same data.
The more diverse your dataset is, the more different methods you can and should use in order to get out of this data as much new as possible. I tried to find a dataset with different data types to have a wide field for action.
The ideal web dashboard should be interactive so that changing the data and its presentation and instantly receiving the visualization is super convenient. Plus it saves time and makes analysis more efficient.
As a result, for my dashboard, I chose products such as (for flat and pivot tables) and for everything else. Both components are absolutely free, and besides that, the WebDataRocks has a special connector for Google Charts and another charting library I want to use.
Google Charts also have maps in their list of available charts, but I used FusionCharts for visualizing country data because they are a little more interactive and user-friendly. This library is free only for non-commercial use, but for my purposes, that was enough.
<H1 align=center>Sales Analytical Dashboard</H1>
<table>
<tr>
<td style="width: 750px;"><div id="wdr-component"></div>
</td>
<td><div id="googlechart-container1" style="width: 650px; height:400px;"></div>
</td>
</tr>
<tr>
<td><div id="fusionmap-container" ></div>
</td>
<td><div id="googlechart-container" ></div>
</td>
</tr>
</table>
<div id="wdr-component2"></div>
After that, we need to add scripts and styles for each library so that we can see what we are getting on the fly. Here are all that I used:
<link rel="stylesheet" type="text/css" href="//cdn.webdatarocks.com/latest/webdatarocks.min.css" />
<script src="//cdn.webdatarocks.com/latest/webdatarocks.toolbar.min.js"></script>
<script src="//cdn.webdatarocks.com/latest/webdatarocks.js"></script>
<script src="//cdn.webdatarocks.com/_codepen/webdatarocks.fusioncharts.js"></script>
<script src="//static.fusioncharts.com/code/latest/fusioncharts.js"></script>
<script src="//static.fusioncharts.com/code/latest/themes/fusioncharts.theme.fint.js"></script>
<script src="//cdn.webdatarocks.com/latest/webdatarocks.googlecharts.js"></script>
<script src="//www.gstatic.com/charts/loader.js"></script>
But many libraries have other extensions, such as themes and animations, so you can add them yourself if needed.
var pivot = new WebDataRocks({
container: "#wdr-component",
toolbar: true,
height: 380,
width: "100%",
report: {
dataSource: {
"dataSourceType": "csv",
"filename": "//cdn.webdatarocks.com/data/data.csv"
},
"slice": {
"rows": [
{
"uniqueName": "Country"
}
],
"columns": [
{
"uniqueName": "Category"
},
{
"uniqueName": "Measures"
}
],
"measures": [
{
"uniqueName": "Price",
"aggregation": "sum"
}
]
}
},
});
In the end, you will also need to add a reportcomplete
event to the pivot
instance, which will call functions to create the remaining elements after the pivot sums up the necessary data and is ready to give it for visualization:
reportcomplete: function() {
pivot.off("reportcomplete");
pivotTableReportComplete = true;
createGoogleChart();
createGoogleChart1();
createFusionMap();
}
Fine! Now we have a pivot and calculated data - we can move on.
var pivotTableReportComplete = false;
var googleChartsLoaded = false;
They will help us understand if the pivot and charts are ready to start working with each other.
Now we need to load the chart from the Google charts library and set the onGoogleChartsLoaded()
function as a callback to google.chartsevent
handler:
google.charts.load('current', {
'packages': ['corechart']
});
google.charts.setOnLoadCallback(onGoogleChartsLoaded);
Next, we will designate a function to create the charts:
function onGoogleChartsLoaded() {
googleChartsLoaded = true;
if (pivotTableReportComplete) {
createGoogleChart();
createGoogleChart1();
}
}
And finally, we can start drawing the charts. We have two types of them: column and pie charts. But they will be created in about the same way:
function createGoogleChart() {
if (googleChartsLoaded) {
pivot.googlecharts.getData({
type: "column"
},
drawChart,
drawChart
);
}
}
function drawChart(_data) {
var data = google.visualization.arrayToDataTable(_data.data);
var options = {
colors: ['#e44a00', '#ffeead', '#d9534f', '#ffad60', '#5bc0de', '#26827E']
};
var chart = new google.visualization.ColumnChart(document.getElementById('googlechart-container'));
chart.draw(data, options);
}
For the pie chart, it will look similar:
function createGoogleChart1() {
if (googleChartsLoaded) {
pivot.googlecharts.getData({
type: "pie"
},
drawChart1,
drawChart1
);
}
}
function drawChart1(_data) {
var data = google.visualization.arrayToDataTable(_data.data);
var options = {
legend: {
position: 'top'
},
colors: ['#68AA23', '#3e6e0c', '#2b5202', '#558c1c', '#75b533', '#95e344']
};
var chart = new google.visualization.PieChart(document.getElementById('googlechart-container1'));
chart.draw(data, options);
}
function createFusionMap() {
var map = new FusionCharts({
"type": "maps/worldwithcountries",
"renderAt": "fusionmap-container",
"width": "100%",
"height": "400",
"dataFormat": "json"
});
The difference in creation will be more in what data this map will show. I want the map to be static, in contrast to the charts, and it remains unchanged no matter what the pivot shows.
pivot.fusioncharts.getData({
type: "maps/" + map.chartType(),
"slice": {
"rows": [
{
"uniqueName": "Country"
}
],
"columns": [
{
"uniqueName": "Category"
},
{
"uniqueName": "Measures"
}
],
"measures": [
{
"uniqueName": "Price",
"aggregation": "sum"
}
]
}
}, function(data) {
data.chart.showLabels = "0";
data.chart.showCanvasBorder = "0";
data.chart.theme = "fint";
data.chart.nullEntityColor = "#cccccc";
data.chart.nullEntityAlpha = "50";
data.colorrange = {
"minvalue": data.extradata.minValue,
"startlabel": "Low",
"endlabel": "High",
"code": "#e44a00",
"gradient": "1",
"color": [
{
"maxvalue": data.extradata.maxValue,
"code": "#6baa01"
}
]
};
delete data.extradata;
map.setJSONData(data);
map.render();
}, function(data) {
data.chart.showLabels = "0";
data.chart.showCanvasBorder = "0";
data.chart.theme = "fint";
data.chart.nullEntityColor = "#cccccc";
data.chart.nullEntityAlpha = "50";
data.colorrange = {
"minvalue": data.extradata.minValue,
"startlabel": "Low",
"endlabel": "High",
"code": "#e44a00",
"gradient": "1",
"color": [
{
"maxvalue": data.extradata.maxValue,
"code": "#6baa01"
}
]
};
delete data.extradata;
map.setJSONData(data);
});
}
var pivot2 = new WebDataRocks({
container: "#wdr-component2",
height: 400,
width: "100%",
report: {
"dataSource": {
"dataSourceType": "csv",
"filename": "//cdn.webdatarocks.com/data/data.csv"
},
"slice": {
"rows": [
{
"uniqueName": "Country"
},
{
"uniqueName": "Business Type"
},
{
"uniqueName": "Color"
},
{
"uniqueName": "Destination"
},
{
"uniqueName": "Discount"
},
{
"uniqueName": "Quantity"
},
{
"uniqueName": "Size"
}
],
"columns": [
{
"uniqueName": "Category"
},
{
"uniqueName": "Measures"
}
],
"measures": [
{
"uniqueName": "Price",
"aggregation": "sum"
}
],
"flatOrder": [
"Country",
"Category",
"Price",
"Business Type",
"Color",
"Destination",
"Discount",
"Quantity",
"Size"
]
},
"options": {
"grid": {
"type": "flat"
}
}
}
});