0
我正在使用Visual Studio 2012/ASP.NET MVC 4制作网站,并且我想使用Flot将图表放在首页上。浮动图表不渲染
该项目的BundleConfig设置为包括整个海军报目录,包括jQuery的:
bundles.Add(new ScriptBundle("~/bundles/flot").IncludeDirectory("~/Scripts/flot", "*.js"));
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
"~/Scripts/jquery-{version}.js",
"~/Scripts/jquery-ui-{version}.js",
"~/Scripts/jquery.unobtrusive*",
"~/Scripts/jquery.validate*"));
的脚本在_Layout.cshtml文件中呈现。
@Scripts.Render("~/bundles/modernizr", "~/bundles/jquery", "~bundles/flot")
的脚本,主页上的观点再次呈现,并且flotcontainer DIV显示了在主页上,但只有一个空白的长方形。
@{
ViewBag.Title = "Home Page";
Scripts.Render("~/bundles/modernizr", "~/bundles/jquery", "~bundles/flot");
}
<div id="flotcontainer" style="width: 600px; height: 400px;"></div>
<script type="text/javascript">
$(function() {
var oilPrices = [[1167692400000, 61.05] ...
...(Flot chart example goes here, nothing wrong with this part)...
});
</script>
当你检查javascript控制台时,你看到了什么错误? – Mark
我看到“TypeError:$ .plot不是函数”。 – alex
错误意味着flot未被正确包含。 “主页视图”是否使用布局(它看起来不像代码片断)?如果您查看页面的源代码,是否会看到如下条目:'