目前我似乎無法在條形圖內生成任何數據。我不確定錯誤是否與我創建的JSON字符串或jQuery代碼有關。無法填充jqPlot條形圖
編輯:(一旦我改變了陣列所產生的基本曲線的單值,但仍然沒有條)
JSON字符串:[{"Name":"Poll Results","Serie":[[10],[14],[14],[19]]}]
的jQuery:
<script type="text/javascript">
//Enable JQuery IntelliSense for Visual Studio
///<reference path="jquery-1.3.2-vsdoc.js2 />
jQuery(document).ready(function() {
urlDataJSON = '/Home/BarChartJSON';
$.getJSON(urlDataJSON, "", function (data) {
var dataLines = [];
var dataLabels = "";
$.each(data, function (entryindex, entry) {
dataLines.push(entry['Serie']);
dataLabels = dataLabels + entry['Name'];
});
Plot(dataLines, dataLabels);
function Plot(dataLines, dataLabels) {
options = {
legend: { show: true },
Title: 'Poll Results',
seriesDefaults: {
renderer: $.jqplot.BarRenderer,
pointLabels: { show: true, location: 'e', edgeTolerance: -15 },
shadowAngle: 135,
renderOptions: {
barDirection: 'horizontal'
}
},
axes: {
yaxis: {
renderer: $.jqplot.CategoryAxisRenderer
}
}
}
}
var plot = $.jqplot('barChart', [dataLines], options);
});
});
</script>
<h2>barChart</h2>
<div id="barChart" style="height:600px;width:600px;"></div>
的屏幕截圖顯示到目前爲止產生了什麼。
我看過JSON字符串,並從中刪除額外的數據。我現在能夠生成基本圖形,但沒有出現條形圖。 –