1
我寫了一小段JavaScript代碼,在django框架中使用highcharts顯示條形圖。 我home.html的包含highcharts在django中不工作
{% extends "base.html" %}
{% block main_content %}
{% load staticfiles %}
<script src="{% static "js/day_of_week.js" %}"></script>
<button class="btn btn-primary" type="button" id="btn_day_of_week">Day of week</button>
<div id = "container">
</div>
{% endblock %}
靜態/ JS/day_of_week.js包含
$(document).ready(function(){
$('#btn_day_of_week').click(function(){
//alert("day_of_week is clicked");
$('#container').highcharts({
chart: {
type: 'column'
},
title: {
text: 'Call Patterns in Week of Day'
},
xAxis: {
categories: [
'Sunday',
'Monday',
'Tuesday',
'Wednesday',
'Thursady',
'Friday',
'Saturday',
]
},
yAxis: {
min: 0,
title: {
text: 'call duration(sec)'
}
},
tooltip: {
headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' +
'<td style="padding:0"><b>{point.y:.1f} mm</b></td></tr>',
footerFormat: '</table>',
shared: true,
useHTML: true
},
plotOptions: {
column: {
pointPadding: 0.2,
borderWidth: 0
}
},
series: [{
name: 'Tokyo',
data: [49.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6]
}, {
name: 'New York',
data: [83.6, 78.8, 98.5, 93.4, 106.0, 84.5, 105.0]
}, {
name: 'London',
data: [48.9, 38.8, 39.3, 41.4, 47.0, 48.3, 59.0
}, {
name: 'Berlin',
data: [42.4, 33.2, 34.5, 39.7, 52.6, 75.5, 57.4]
}]
});
});
});
的alert("day_of_week is clicked");
運作良好,但該圖沒有顯示。如何使其顯示?
你能看到控制檯中的任何錯誤? –
在控制檯中沒有錯誤 –
你有沒有用於'#容器的CSS?如果不是,你可以改變它:'
'? –