我需要一些幫助來更改欄寬。我正在創建一個簡單的水平條形圖,需要更改條形的寬度取決於百分比數據。的jsfiddle鏈接http://jsfiddle.net/kmc3ohab/2/使用javascript更改欄寬度
在此先感謝
var data = {
"box1": {
"bar1": "80%",
"bar2": "60%",
"bar3": "40%",
"bar4": "50%",
"total": "60%",
},
};
$(document).ready(function() {
$(".score-text").html(data.box1.total);
$(".data").text(data.box1.bar1);
$(".data").text(data.box1.bar2);
$(".data").text(data.box1.bar3);
$(".data").text(data.box1.bar4);
});
body {
\t background: #efefef;
\t width: 100%;
\t margin: 0px;
\t text-align: center;
}
h2 {
\t font-family: 'Noto Sans', serif;
\t color: #b71f38;
\t font-weight: 300;
\t margin: 0px;
}
h3 {
\t font-family: 'Noto Sans', serif;
\t color: #444444;
\t font-weight: 200;
\t margin: 0px;
}
#colLeft {
\t width: 50%;
\t float: left;
}
#colRight {
\t width: 50%;
\t float: right;
}
#row {
\t background: #e2e2e2;
\t width: auto;
\t height: 230px;
\t margin: 15px;
\t border-radius: 5px;
}
#insideColLeft {
\t width: 30%;
\t float: left;
}
#insideColRight {
\t width: 69%;
\t float: right;
\t padding-top: 8px;
\t padding-right: 5px;
}
.circle {
\t margin-left: auto;
\t margin-right: auto;
\t border-radius: 50%;
\t width: 150px;
\t position: relative;
\t background: #b71f38;
}
.circle:before {
\t content: "";
\t display: block;
\t padding-top: 100%;
}
.circle-inner {
\t position: absolute;
\t top: 0;
\t left: 0;
\t bottom: 0;
\t right: 0;
\t text-align: center;
}
.score-text {
\t margin: auto;
\t position: absolute;
\t top: 0;
\t left: 0;
\t bottom: 0;
\t right: 0;
\t height: 1em;
\t line-height: 1em;
\t font-size: 30px;
\t font-family: 'Fjalla One', sans-serif;
\t color: #ffffff;
}
.date {
\t font-family: 'Fjalla One', sans-serif;
\t text-align: center;
\t color: #333333;
}
ul.graph {
\t margin: 0;
\t padding: 0;
\t list-style-type: none;
}
\t
ul.graph li {
\t margin: 10px;
\t height: 25px;
\t background: #ccc;
\t color: #fff;
}
\t
ul.graph li.data {
\t background: #f4ebb8;
}
\t
<div id="row">
<h2>Title</h2>
<h3>Subtitle</h3>
<div id="insideColLeft">
<div class="circle">
<div class="circle-inner">
<div class="score-text">
</div>
</div>
</div>
</div>
<div id="insideColRight">
<ul class="graph">
<li class="data">bar 1</li>
<li class="data">bar 2</li>
<li class="data">bar 3</li>
<li class="data">bar 4</li>
</ul>
</div>
</div>
如果我有超過1個數據集?我如何做循環來檢查每個數據?另外,如果我需要從本地csv文件加載數據。爵士小提琴更新http://jsfiddle.net/kmc3ohab/6/
你的問題是,目前所有酒吧都設置爲'50%',但他們應該分別像80,60,40,50? –