我正在嘗試使用jqPlot條形圖顯示條形圖。我正在做代碼,在Internet Explorer中顯示圖表。但是對於相同的代碼表,不會在Crome和Mozilla瀏覽器中顯示。 我所提供的代碼如下─jqPlot條形圖圖表不顯示在Chrome和Mozilla中
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page session="false" %>
<html>
<head>
<style>
<title>Home</title>
<script src="http://code.jquery.com/jquery-1.8.3.js"></script>
<script src="https://github.com/douglascrockford/JSON-js/blob/master/json2.js"> </script>
<script type="text/javascript" src="../resources/jQuery/jquery.min.js"></script>
<script type="text/javascript" src="../resources/jQuery/jquery.jqplot.min.js"></script>
<script type="text/javascript" src="../resources/jQuery/plugins/jqplot.barRenderer.min.js"></script>
<script type="text/javascript" src="../resources/jQuery/plugins/jqplot.pieRenderer.min.js"></script>
<script type="text/javascript" src="../resources/jQuery/plugins/jqplot.categoryAxisRenderer.min.js"></script>
<script type="text/javascript" src="../resources/jQuery/plugins/jqplot.pointLabels.min.js"> </script>
<link rel="stylesheet" type="text/css" href="../resources/jQuery/jquery.jqplot.min.css" />
<script>
function drawChart() {
alert("In draw chart");
var s1 = [2, 6, 7];
var s2 = [7, 5, 3];
var s3 = [2, 3, 5];
var s4 = [1, 7, 2];
// chart data
var dataArray = [s1, s2, s3, s4];
// x-axis ticks
var ticks = ['Jan', 'Feb', 'Mar'];
// chart rendering options
var options = {
seriesDefaults: {
renderer:$.jqplot.BarRenderer
},
axes: {
xaxis: {
renderer: $.jqplot.CategoryAxisRenderer,
ticks: ticks
}
}
};
// draw the chart
$.jqplot('showData', dataArray, options);
}// end
</script>
</head>
<body>
<button value="Get Employee Data" onclick="drawChart()">Get Chart</button>
<div id="showData" style="height: 400px; width: 400px;"></div>
</body>
</html>
爲什麼此代碼不能用於克羅默和Mozilla瀏覽器中工作嗎?
您是否檢查過這些瀏覽器的控制檯是否有錯誤? –
是的,沒有任何錯誤 –
'var dataArray = [s1,s2,s3,24];',是不是應該是s4,而不是24? – Mark