Based on this Highcharts example (javascript code included in a HTML): http://jsfiddle.net/f4Ef7/
I have a template where I want to embed that JavaScript code without having to include any static. Anything not related with JS is being processed by the browser. Currently my views.py looks like:
# -*- encoding: utf-8 -*-
from django.shortcuts import render
from django.http import HttpResponse
from tfgplot.models import estado_foneras
from django.template import RequestContext, loader
def index(request):
template = loader.get_template('tfgplot/index.html')
context = RequestContext(request)
return render(request, 'tfgplot/index.html', context)
My application is called tfgplot and the template index.html looks like:
<div id=container style=min-width: 300px; height: 300px; margin: 1em>
<script src=http://code.highcharts.com/highcharts.js></script>
<script src=http://code.highcharts.com/modules/exporting.js></script>
<head></head>
<body>
<div>
<script type=text/javascript>
{% autoescape off %}
$('#container').highcharts({
xAxis: {
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
},
series: [{
data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
}]
});
{% endautoescape %}
</script>
</div>
</body>
This should create a graphic like the one that can be seen in the link but I'm not able to see that graphic I'm expecting, any ideas?