Quad Data Chart
This is a dynamic quad data chart
by Shawn Wood
HTML
<script src="https://code.jquery.com/jquery-3.4.1.slim.js"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.js"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.css">
<!--
Bootstrap docs: https://getbootstrap.com/docs
-->
<div class="container-fluid quad">
<div class="row">
<div class="col-md-6 ">
<div class="outer ">
<div class="inner ">
<div class="content normal">
<ul id="normalQuad">
</ul>
</div>
<i class="bottom right"></i>
</div>
</div>
</div>
<div class="col-md-6 ">
<div class="outer">
<div class="inner">
<div class="content high">
<ul id="highQuad">
</ul>
</div>
<i class="bottom left"></i>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6 ">
<div class="outer">
<div class="inner">
<i class="top right"></i>
<div class="content low">
<ul id="lowQuad">
</ul>
</div>
</div>
</div>
</div>
<div class="col-md-6 ">
<div class="outer">
<div class="inner">
<i class="top left"></i>
<div class="content medium">
<ul id="mediumQuad">
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
CSS
.quad .col-md-6 {
padding-right: 0px;
padding-left: 0px;
}
.low {
background-color: green;
border-radius: 0px 0px 0px 30px;
height: 300px;
padding-top:35px;
}
.normal {
background-color: yellow;
border-radius: 30px 0px 0px 0px;
height: 300px;
padding-top:35px;
}
.medium {
background-color: orange;
border-radius: 0px 0px 30px 0px;
height: 300px;
padding-top:35px;
}
.high {
background-color: red;
border-radius: 0px 30px 0px 0px;
height: 300px;
padding-top:35px;
}
.outer {
overflow: hidden;
}
.inner {
border: 0px solid #888;
}
.inner i {
width: 180px;
height: 180px;
border: 0px solid #888;
border-radius: 50%;
background-color: #fff;
}
.inner .top {
margin-top: -90px;
}
.inner .bottom {
margin-top: -90px;
margin-bottom: -94px;
}
.inner .left {
float: left;
margin-left: -90px;
}
.inner .right {
float: right;
margin-right: -90px;
}
.content {
min-height: 160px;
}
JavaScript
var quadData = [{
"name": "Testing 1",
"type": "low"
},
{
"name": "Another Test",
"type": "low"
},
{
"name": "More Testing",
"type": "low"
},
{
"name": "something",
"type": "normal"
},
{
"name": "another something",
"type": "normal"
},
{
"name": "more text",
"type": "high"
},
{
"name": "testing another one",
"type": "high"
},
{
"name": "quad texting",
"type": "medium"
},
{
"name": "somehting great",
"type": "medium"
},
{
"name": "resting now",
"type": "low"
},
{
"name": "Raptor",
"type": "low"
},
{
"name": "some piece of work",
"type": "normal"
}
];
var populateQuad = function(data) {
if (typeof data === undefined || data === null) {
data = [];
}
var listitems = [{
"id": "lowQuad",
"type": "low"
}, {
"id": "normalQuad",
"type": "normal"
}, {
"id": "mediumQuad",
"type": "medium"
}, {
"id": "highQuad",
"type": "high"
}];
for(let i = 0; i < data.length; i++){
for(let j = 0; j < listitems.length; j++){
if(data[i].type === listitems[j].type)
$('#' + listitems[j].id).append('<li>' + quadData[i].name + '</li>')
}
}
// Loop through the data
};
$(document).ready(function(){
populateQuad(quadData);
});