Create the HTML, CSS, and Javascript files below and you are off to the races. Click on the file name to get the code content for each.
Ensure that your actual JavaScript filename matches the script element in the HTML <script src="code.js"></script>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Dashboard Template</title>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<h1>Data Dashboard</h1>
<div id='page'>
<div class="card">
<div id="chart1"></div>
</div>
<div class="card">
<div id="chart2"></div>
</div>
</div>
<!--Javascript-->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/PapaParse/5.1.0/papaparse.min.js"></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js'></script>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script src="https://cdn.jsdelivr.net/alasql/0.2/alasql.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/idewcomputing/code-dataviz-dashboard@master/src/viz.js"></script>
<script src="code.js"></script>
</body>
</html>
function setup() {
var degreesLink = 'https://docs.google.com/spreadsheets/d/e/2PACX-1vQUwF7K2lCH8CxQPJW-X7NqENwuwUM4eAeNUKw3j6yppO0tipC6yUB2hQPtRBZf19mmVbM5TdkkengZ/pub?gid=1030028695&single=true&output=csv';
viz.loadTable(degreesLink,"Degrees").then(composeDegreeCharts);
window.onresize = composeDegreeCharts;
}
function composeDegreeCharts() {
viz.chart({
sql:"SELECT Major, StartingMedianSalary FROM Degrees",
chartType:"BarChart",
containerId:"chart1"
});
viz.chart({
sql:"SELECT * FROM Degrees",
chartType:"Table",
containerId:"chart2"
});
}
window.onload = setup;
body {
padding: 15px;
margin: 0;
background: #eee;
}
#page {
display: grid;
/* grid-template-columns: repeat(auto-fill, minmax(400px, 1fr)); */
grid-gap: 15px;
}
h1 {
font-family: 'Arial';
text-align: center;
}
.card {
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.4), 0 6px 20px 0 rgba(0, 0, 0, 0.4);
overflow: hidden;
background: white;
}
.description {
padding: 15px 7px;
}
Note: August 30, 2021 the Papaparse Javascript library was added to the template in the HTML above with the following line ...
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/PapaParse/5.1.0/papaparse.min.js"></script>
Copyright and License
Copyright © 2018-2019 Jim Lyst and Michael Frontz, Indiana University School of Informatics and Computing at IUPUI
This material is part of the Computing by Design high school computer science curriculum developed for the Informatics Diversity-Enhanced Workforce (iDEW) program, an award-winning community partnership in central Indiana that is broadening student participation in computing and helping students develop the skills essential for success in the 21st century workplace. The iDEW program is managed by the Indiana University School of Informatics and Computing at IUPUI.
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. You are free to use, share, or adapt this material for noncommercial purposes as long as you provide proper attribution and distribute any copies or adaptations under this same license.