r.2 - AssetTitle_BandedGauge
by Steve Thompson
HTML
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/highcharts-more.js"></script>
<div class="container">
<div class="cont-box-shadow">
<div class="info">
<div class="var-icon">
<div class="var-structure var-blue">
(
</div>
<div class="var-type var-blue">
A
</div>
<div class="var-structure var-blue">
)
</div>
</div>
<div class="var-name">Square Feet</div>
<a href="#">
<div class="info-icon"></div>
</a>
<a href="#">
<div class="alert-icon"></div>
</a>
</div>
<div class="chart-container">
<div id="chart1"></div>
</div>
<div class="menu-tools">
<a href="#">
<div class="nD-edit sm-icons" title="Edit"></div>
</a>
<a href="#">
<div class="nD-trash sm-icons" title="Delete"></div>
</a>
</div>
</div>
</div>
CSS
.container {
width: 196px;
height: 196px;
background-color: #eceded;
position: relative;
padding: 2px;
overflow: hidden;
}
.cont-box-shadow {
width: 100%;
height: 100%;
background-color: white;
-webkit-box-shadow: 0px 1px 1px 1px rgba(171, 172, 172, 1);
-moz-box-shadow: 0px 1px 1px 1px rgba(171, 172, 172, 1);
box-shadow: 0px 1px 1px 1px rgba(171, 172, 172, 1);
}
.info {
width: 100%;
height: 25px;
background-color: #555555;
margin: 0 auto;
}
.var-icon {
position: relative;
float: left;
margin: 5px;
width: 19px;
height: 14px;
font-size: 12px;
}
.var-blue {
color: #42a5f5;
}
.var-structure {
position: relative;
float: left;
}
.var-type {
position: relative;
float: left;
}
.var-name {
font-size: 12px;
color: white;
position: relative;
float: left;
margin-top: 5px;
}
.alert-icon {
display: none;
background: url(http://i.imgur.com/TcAIU77.png) no-repeat;
position: relative;
float: right;
margin: 5px 3px;
width: 16px;
height: 14px;
}
.info-icon {
background: url(http://i.imgur.com/NhumKdn.png) no-repeat;
position: relative;
float: right;
margin: 5px 5px 5px 0;
width: 14px;
height: 14px;
}
.info-icon:hover {
background: url(http://i.imgur.com/Y4NJcU5.png) no-repeat;
}
.chart-container {
width: 100%;
height: 77%;
}
#chart1 {
cursor: pointer;
width: 100%;
height: 100%;
margin: 0 auto;
position: relative;
}
.menu-tools {
display: none;
position: relative;
float: right;
margin-right: 5px;
}
.container:hover .menu-tools {
display: block;
}
.sm-icons {
width: 15px;
height: 15px;
position: relative;
float: left;
margin-right: 5px;
}
.nD-edit {
background: url(http://i.imgur.com/2JA9xGB.png) no-repeat;
}
.nD-edit:hover {
background: url(http://i.imgur.com/wl0o0oZ.png) no-repeat;
}
.nD-trash {
background: url(http://i.imgur.com/5V6UKIT.png) no-repeat;
}
.nD-trash:hover {
background: url(http://i.imgur.com/PjzC5eV.png) no-repeat;
}
JavaScript
$(function() {
var bool_data = [2477, 564];
var bool_per = bool_data[0] / (bool_data[1] + bool_data[0]) * 100;
bool_per = bool_per.toFixed(0) + '%';
$('#chart1').highcharts({
chart: {
type: 'pie'
},
colors: ['#4c4c4c', '#acacac'],
credits: {
enabled: false
},
exporting: {
enabled: false
},
legend: {
enabled: false
},
title: {
text: bool_per,
verticalAlign: 'bottom',
y: -30,
style: {
fontSize: '22px'
}
},
tooltip: {
borderWidth: 0,
backgroundColor: "#3c3f42",
borderRadius: 0,
hideDelay: 500,
shadow: false,
headerFormat: '',
pointFormat: '<span style="color: white; font-weight: bold;">{point.y:,.0f} ({point.percentage:,.0f}%)</span><br/>'
},
plotOptions: {
series: {
states: {
hover: {
enabled: false
}
},
point: {
events: {
mouseOver: function() {
this.options.oldColor = this.color;
this.graphic.attr("fill", "#f37021");
},
mouseOut: function() {
this.graphic.attr("fill", this.options.oldColor);
}
}
},
},
pie: {
cursor: 'pointer',
dataLabels: {
enabled: false
},
startAngle: -90,
endAngle: 90,
innerSize: '50%',
size: '175%',
center: ['50%', '90%'],
useHTML: true,
formatter: function() {
return '<span style="color:' + this.point.color + '"><b>' + this.point.name + '</b></span>';
}
}
},
series: [{
data: bool_data
}]
});
});