Skip to content

Instantly share code, notes, and snippets.

@elliots
Forked from bacall213/options.js
Last active December 21, 2015 22:18
Show Gist options
  • Save elliots/6373808 to your computer and use it in GitHub Desktop.
Save elliots/6373808 to your computer and use it in GitHub Desktop.
Based on bcall's excellent work...
return {
"name": "Bandwidth In/Out",
"deviceMap": [
{ "deviceId": [530,531,532,533], "minimum": 1, "maximum": 1},// Incoming
{ "deviceId": [540,541,542,543], "minimum": 1, "maximum": 1} // Outgoing
],
"forceDeviceMapGroup": true
}
/* General */
.column {
width: 50%;
height: 100%;
top: 0%;
position: relative;
float: left;
background: white;
}
.label {
position: absolute;
top: 80px;
width: 100%;
text-align: center;
color: rgba(0,0,0,0.3);
}
.tempvalue {
position: absolute;
top: 45px;
width: 100%;
text-align: center;
font-size: 45px;
font-weight: bold;
left: -8px;
.tempunits {
font-size: 14px;
font-weight: normal;
vertical-align: super;
position: relative;
top: -10px;
}
.hitemptext {
position: absolute;
font-weight: bold;
font-size: 10px;
top: 2px;
left: 82px;
text-align: center;
width: 100%;
color: hsl(20,75%,65%);
}
.lotemptext {
position: absolute;
font-weight: bold;
font-size: 10px;
top: 14px;
left: 83px;
text-align: center;
width: 100%;
color: hsl(203,60%,56%);
}
}
/* Humidity Module */
.humidvalue {
position: absolute;
top: 45px;
width: 100%;
text-align: center;
font-size: 45px;
font-weight: bold;
left: 0px;
.humidunits {
font-size: 14px;
font-weight: normal;
vertical-align: super;
position: relative;
top: -10px;
}
.hihumidtext {
position: absolute;
font-weight: bold;
font-size: 10px;
top: 2px;
left: 42px;
text-align: center;
width: 100%;
color: hsl(20,75%,65%);
}
.lohumidtext {
position: absolute;
font-weight: bold;
font-size: 10px;
top: 14px;
left: 43px;
text-align: center;
width: 100%;
color: hsl(203,60%,56%);
}
}
/* Sparkline styling */
.sparkline {
position: relative;
top: 105px;
width: 90%;
height: 85px;
margin-left: auto;
margin-right: auto;
line-height: 30px;
border: 1px solid hsl(0,0%,90%);
background: hsl(0,0%,95%);
canvas {
width: 100%;
height: 30px;
}
}
/* Temperature customizations */
.temperature {
color: hsl(45,100%,45%);
}
/* Humidity customizations */
.humidity {
color: hsl(203,60%,56%);
}
<div class="temperature column">
<div class="label">Incoming</div>
<div class="tempvalue">
<span class="text"></span>
<sup class="tempunits">kb</sup>
<span class="hitemptext"></span>
<span class="lotemptext"></span>
</div>
<div class="sparkline"></div>
</div>
<div class="humidity column">
<div class="label">Outgoing</div>
<div class="humidvalue">
<span class="text"></span>
<sup class="humidunits">kb</sup>
<span class="hihumidtext"></span>
<span class="lohumidtext"></span>
</div>
<div class="sparkline"></div>
</div>
var sparkHumidity = element.find(".humidity .sparkline");
var sparkTemperature = element.find(".temperature .sparkline");
var dataHumidity = [];
var dataTemperature = [];
var sparklineOptions = {
width: '100%',
height: '85px'
}
function SetHumidity(value) {
element.find(".humidity .humidvalue .text").html(value);
dataHumidity.push(value);
sparkHumidity.sparkline(dataHumidity, sparklineOptions);
element.find(".humidity .humidvalue .hihumidtext").html("HI: " + Math.max.apply(null, dataHumidity));
element.find(".humidity .humidvalue .lohumidtext").html("LO: " + Math.min.apply(null, dataHumidity));
};
function SetTemperature(value) {
element.find(".temperature .tempvalue .text").html(value);
dataTemperature.push(value);
sparkTemperature.sparkline(dataTemperature, sparklineOptions);
element.find(".temperature .tempvalue .hitemptext").html("HI: " + Math.max.apply(null, dataTemperature));
element.find(".temperature .tempvalue .lotemptext").html("LO: " + Math.min.apply(null, dataTemperature));
};
scope.onData = function(data) {
if (data.D < 540) {
SetHumidity(Math.floor(data.DA));
} else {
SetTemperature(Math.floor(data.DA));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment