function SetRunColors() {
$.each($('.runColor'),
function(i, val) {
var rtArray = val.title.split(': ');
var titleArray = val.title.split('Prod %:');
var percentage = titleArray[1].replace('%', '');
var rt = rtArray[1];
rt = rt.split(' ');
var rtVal = rt[0];
var dec = parseFloat(percentage) / 100;
var newH = 120 * dec;
if (rtVal < 1) {
newH = 120;
}
var color = "hsl(" + newH + ",100% , 50% )";
var lightColor = "hsl(" + newH + ",100% , 85% )";
var background = "linear-gradient(" + lightColor + "," + color + ")";
$(this).css('background', background);
});
.runColor, .runScrap {
background-color: green;
text-align: center;
height: 30px;
background: linear-gradient(lightgreen, green);
-webkit-box-shadow: #B4B5B5 1px 1px 1px;
-moz-box-shadow: #B4B5B5 1px 1px 1px;
box-shadow: #B4B5B5 1px 1px 1px;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
}
<div id="2" class="runColor" title="
Start of First : 9.9
Start: 4/20/2022 08:00:12
Stop: 4/20/2022 08:10:07
Prod (Bakers Dozen): 27
Prod %: 45.37%" style="margin-top: 10px; float: left; width: 27px; background: linear-gradient(rgb(255, 248, 179), rgb(255, 231, 0));"></div><div id="3" class="runColor" title="
Running : 10.0
Start: 4/20/2022 08:10:07
Stop: 4/20/2022 08:20:05
Prod (Bakers Dozen): 60
Prod %: 100.48%" style="margin-top: 10px; float: left; width: 27px; background: linear-gradient(rgb(179, 255, 179), rgb(0, 255, 2));"></div><div id="4" class="runColor" title="
Running : 9.9
Start: 4/20/2022 08:20:05
Stop: 4/20/2022 08:30:00
Prod (Bakers Dozen): 43
Prod %: 72.24%" style="margin-top: 10px; float: left; width: 27px; background: linear-gradient(rgb(221, 255, 179), rgb(142, 255, 0));"></div><div id="5" class="runColor" title="
Running : 10.1
Start: 4/20/2022 08:30:00
Stop: 4/20/2022 08:40:05
Prod (Bakers Dozen): 55
Prod %: 90.87%" style="margin-top: 10px; float: left; width: 28px; background: linear-gradient(rgb(192, 255, 179), rgb(47, 255, 0));"></div><div id="6" class="runColor" title="
Running : 9.9
Start: 4/20/2022 08:40:05
Stop: 4/20/2022 08:50:00
Prod (Bakers Dozen): 45
Prod %: 75.63%" style="margin-top: 10px; float: left; width: 27px; background: linear-gradient(rgb(216, 255, 179), rgb(124, 255, 0));"></div><div id="7" class="runColor" title="
Running : 10.1
Start: 4/20/2022 08:50:00
Stop: 4/20/2022 09:00:05
Prod (Bakers Dozen): 52
Prod %: 85.93%" style="margin-top: 10px; float: left; width: 28px; background: linear-gradient(rgb(200, 255, 179), rgb(72, 255, 0));"></div><div id="8" class="runColor" title="
Running : 9.9
Start: 4/20/2022 09:00:05
Stop: 4/20/2022 09:10:00
Prod (Bakers Dozen): 40
Prod %: 67.24%" style="margin-top: 10px; float: left; width: 27px; background: linear-gradient(rgb(229, 255, 179), rgb(167, 255, 0));"></div><div id="9" class="runColor" title="
Running : 10.1
Start: 4/20/2022 09:10:00
Stop: 4/20/2022 09:20:05
Prod (Bakers Dozen): 59
Prod %: 97.49%" style="margin-top: 10px; float: left; width: 28px; background: linear-gradient(rgb(182, 255, 179), rgb(13, 255, 0));"></div><div id="10" class="runColor" title="
Running : 9.9
Start: 4/20/2022 09:20:05
Stop: 4/20/2022 09:30:00
Prod (Bakers Dozen): 50
Prod %: 84.04%" style="margin-top: 10px; float: left; width: 27px; background: linear-gradient(rgb(203, 255, 179), rgb(81, 255, 0));"></div><div id="11" class="runColor" title="
Running : 10.1
Start: 4/20/2022 09:30:00
Stop: 4/20/2022 09:40:05
Prod (Bakers Dozen): 37
Prod %: 61.15%" style="margin-top: 10px; float: left; width: 28px; background: linear-gradient(rgb(238, 255, 179), rgb(198, 255, 0));"></div><div id="12" class="runColor" title="
Running : 9.9
Start: 4/20/2022 09:40:05
Stop: 4/20/2022 09:50:00
Prod (Bakers Dozen): 0
Prod %: 0.00%" style="margin-top: 10px; float: left; width: 27px; background: linear-gradient(rgb(255, 179, 179), rgb(255, 0, 0));"></div><div id="13" class="runColor" title="
Running : 10.1
Start: 4/20/2022 09:50:00
Stop: 4/20/2022 10:00:06
Prod (Bakers Dozen): 20
Prod %: 33.05%" style="margin-top: 10px; float: left; width: 28px; background: linear-gradient(rgb(255, 229, 179), rgb(255, 169, 0));"></div><div id="14" class="runColor" title="
Running : 2.8
Start: 4/20/2022 10:00:06
Stop: 4/20/2022 10:02:53
Prod (Bakers Dozen): 20
Prod %: 119.44%" style="margin-top: 10px; float: left; width: 7px; background: linear-gradient(rgb(179, 255, 208), rgb(0, 255, 99));"></div>