I am trying to render an output like the one in the picture
Right now, I am trying to pass all the numeric values into an array, and then set the grey bars' lengths to the maximum of those values This is what I have so far, but it is not passing any values:
var contentValues = $('facet-amount').text();
var arr = parseInt(contentValues);
$(".facet-percentage").width(Math.max(...arr));
.facet {
position: relative;
border: 1px solid #dcdcdc;
margin-top: 13px;
}
.facet-title {
display: inline-block;
}
.facet-amount {
display: inline-block;
position: absolute;
right: 2px;
}
.facet-percentage {
background-image: -webkit-linear-gradient(top, #f8f8f8, #e5e5e5);
display: inline-block;
height: 10%;
position: absolute;
z-index: -1;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="content-type-facet" class="facet">
<div class="facet-header">
<h3>Content Type</h3>
</div>
<div>
<span class="facet-percentage" style=""></span>
<span class="facet-title">Chapter</span>
<span class="facet-amount">400</span>
</div>
<div>
<span class="facet-percentage" style=""></span>
<span class="facet-title">Article</span>
<span class="facet-amount">200</span>
</div>
<div>
<span class="facet-percentage" style=""></span>
<span class="facet-title">Reference Work Entry</span>
<span class="facet-amount" id='ciao'>207</span>
</div>
<div>
<span class="facet-percentage" style=""></span>
<span class="facet-title">Protocol</span>
<span class="facet-amount">16</span>
</div>
<div>
<span class="facet-percentage" style=""></span>
<span class="facet-title">Book</span>
<span class="facet-amount">2</span>
</div>
</div>

.facet-percentageshould be 400px?