简体   繁体   中英

Flot chart doesn't render

I'm making a website using Visual Studio 2012 / ASP.NET MVC 4, and I would like to put a chart on the front page using Flot.

The project's BundleConfig is set up to include the entire Flot directory, and to include 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*"));

The scripts are rendered in the _Layout.cshtml file.

@Scripts.Render("~/bundles/modernizr", "~/bundles/jquery", "~bundles/flot")

The scripts are rendered again on the home page's View, and the flotcontainer div shows up on the home page but only as a blank rectangle.

@{
    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>

Mark's answer turned out to be correct - the problem was that "~bundles/flot" was missing a backslash, and it should have been written as "~/bundles/flot". Thanks Mark!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM