Javascript jqPlot:$。jqPlot不是函数错误
我需要在网站上创建图表 在我的HTML代码中,我创建了一个ID为的div 这是我的HTML代码:Javascript jqPlot:$。jqPlot不是函数错误,javascript,jquery,charts,jqplot,Javascript,Jquery,Charts,Jqplot,我需要在网站上创建图表 在我的HTML代码中,我创建了一个ID为的div 这是我的HTML代码: <script src="/js/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="/styles/jquery.jqplot.min.css" /> <script language="javascript" type="text/javascript" src="/
<script src="/js/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="/styles/jquery.jqplot.min.css" />
<script language="javascript" type="text/javascript" src="/js/jquery.jqplot.js"></script>
<script language="javascript" type="text/javascript" src="/js/graph.js"></script>
<body>
<div id="graph" style="height:400px;width:300px;></div> //i want to have my chart here
</body>
所以我的问题是浏览器控制台上有一个错误:$.jqplot不是一个函数
有什么想法吗?确保jquery-*.js顺序在jqPlot.js之前 并在所有脚本标记上使用language=javascript type=text/javascript
致以最诚挚的问候,您收到此错误,因为您在$document.readyfunction中有jqplot。试试这样的
$(document).ready(function(){
GetChart();
});
function GetChart(){
var chart_data = [[1, 2],[3,5.12],[5,13.1],[7,33.6],[9,85.9],[11,219.9]];
$('#graph').jqplot([chart_data], {
title:'Default Bar Chart',
seriesDefaults:{
renderer:$.jqplot.BarRenderer
},
axes:{
xaxis:{
renderer: $.jqplot.CategoryAxisRenderer
}
}
});
}
以下是一个工作示例-
要使此示例起作用,您需要将以下引用添加到项目中-
jquery.min.js
jquery.jqplot.js
jquery.jqplot.css
jqplot.barRenderer.js
jqplot.barRenderer.min.js
jqplot.categoryAxisRenderer.js
jqplot.categoryAxisRenderer.min.js
确保包含的文件存在于该路径上,并且名称正确,jquery.jqplot.js而不是jquery.jqplot.min.js谢谢您的回答,但我已经包含了jquery.plot.js。我也尝试过使用.min文件。在jqplot js之前添加jquery lib。jqplot之前是否已经包含jquery?感谢您的回答:虽然添加type=text/javascript的风格不错,但根据,language属性已经被弃用很长时间了,不应该使用。至于依赖项的排序,很明显OP已经按照您的建议对其源进行了排序
jquery.min.js
jquery.jqplot.js
jquery.jqplot.css
jqplot.barRenderer.js
jqplot.barRenderer.min.js
jqplot.categoryAxisRenderer.js
jqplot.categoryAxisRenderer.min.js