Sunday, April 28, 2013

flot not working when page is served by Django

Hi all,

I'm trying to get any simple flot graph to display at this point. my index.html template file is as shown below. If I load the html file in a browser directly it works great.  When served through django dev server the page is blank.
I have added the following to my settings to ensure that i am pointing to directory where js libraries are:

       STATICFILES_DIRS = {
                      '/home/matt/Web/flot',
       }

There are no errors in the dev server console when loading the page.

Any ideas? 

Thanks.

Matt

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Sample chart</title>
<link href="file:///home/matt/Web/flot/examples/examples.css" rel="stylesheet" type="text/css">
<!--[if lte IE 8]><script language="javascript" type="text/javascript" src="file:///home/matt/Web/flot/excanvas.min.js"></script><![endif]-->
<script language="javascript" type="text/javascript" src="file:///home/matt/Web/flot/jquery.js"></script>
<script language="javascript" type="text/javascript" src="file:///home/matt/Web/flot/jquery.flot.js"></script>
<script language="javascript" type="text/javascript" src="file:///home/matt/Web/flot/jquery.flot.pie.js"></script>
<script type="text/javascript">
$(document).ready(function () {

var data = [
    { label: "IE",  data: 19.5},
    { label: "Safari",  data: 4.5},
    { label: "Firefox",  data: 36.6},
    { label: "Opera",  data: 2.3},
    { label: "Chrome",  data: 36.3},
    { label: "Other",  data: 0.8}
];

$.plot($("#placeholder"), data, 
{
        series: {
            pie: { 
                show: true
            }
        },
        legend: {
            show: false
        }
});

// Add the Flot version string to the footer

$("#footer").prepend("Flot " + $.plot.version + " &ndash; ");
});

</script>
</head>
<body>

<div id="content">

<div class="demo-container">
<div id="placeholder" class="demo-placeholder"></div>
</div>

</body>
</html>

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments:

Post a Comment