2014-07-03 80 views
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> 
+0

當你檢查javascript控制檯時,你看到了什麼錯誤? – Mark

+0

我看到「TypeError:$ .plot不是函數」。 – alex

+0

錯誤意味着flot未被正確包含。 「主頁視圖」是否使用佈局(它看起來不像代碼片斷)?如果您查看頁面的源代碼,是否會看到如下條目:'