0
我目前在製作水平條形圖寬度時遇到了麻煩。目前的問題是我不知道應如何放置我的「」和「」,以便obj.sightingCount
可以用作buildGraph
函數的寬度。Javascript /圖的jquery寬度
CSS:
div.bar {
display: inline-block;
text-align: right;
padding-right: 5px;
background-color: blue;
}
div.year {
display: inline-block;
}
的jQuery/JavaScript的
$.ajax({
url: "api/UFOSightings",
method: "GET",
timeout: 10000,
success: buildGraph,
error: myError
});
function myError(data) {
}
function buildGraph(data) {
$.each(data, function (index, obj) {
$('#graph').append('<div><div class="year">' + obj.sightingYear + '</div><div class="bar" style= width: "obj.sightingCount%;" >' + obj.sightingCount + '</div></div>');
})}
非常感謝你:) – SpatZan