javascript - How do I obtain a Chart instance for Chart.js -
i using python/django default django templates. have in head (other django static files in location work fine):
<script type="text/javascript" src="{% static "js/chart.min.js" %}"></script>
naturally, have chart.min.js extracted master chart.js download static js directory.
in body have:
<div class="graph"> <canvas id="dgraph" width="600" height="400"></canvas> </div>
also in body have:
<script type="text/javascript" src="{% static "js/stuff.js" %}"></script>
in stuff.js have:
var data = [ { value: 20, color:"#878bb6" }, { value : 40, color : "#4acab4" }, { value : 10, color : "#ff8153" }, { value : 30, color : "#ffea88" } ];
// context of canvas element want select
var ctx = document.getelementbyid("dgraph").getcontext("2d"); new chart(ctx).doughnut(data, {});
however, when try , display in browser (chrome happens) see in console:
uncaught referenceerror: chart not defined
where on earth chart object obtained from? seems pretty fundamental , feel if i've followed every instruction available on google , stackoverflow. please help!
the chart
object defined in chart.min.js. looks script isn't being loaded.
i think you're missing quotes around value of src
attribute in <script>
tag in header - try:
<script type="text/javascript" src="{% static 'js/chart.min.js' %}"></script>
Comments
Post a Comment