I have declared t in my views. when I run my django application it shows a blank page but when I press ctrl+u I can see my y values are rendered correctly but my x values are rendered blank . my goal is to have in x the current time .
<script type="text/javascript">
$(function () {
$(document).ready(function () {
Highcharts.setOptions({
global: {
useUTC: false
}
});
$('#container').highcharts({
chart: {
type: 'spline',
animation: Highcharts.svg, // don't animate in old IE
marginRight: 10,
events: {
load: function () {
// set up the updating of the chart each second
var series = this.series[0];
setInterval(function () {
var x = (new Date()).getTime(), // current time
y = {{ t }} ;
series.addPoint([x, y], true, true);
}, 3000);
}
}
},
title: {
text: 'Live temperature sensor values'
},
xAxis: {
type: 'datetime',
tickPixelInterval: 150
},
yAxis: {
title: {
text: 'Value'
},
plotLines: [{
value: 0,
width: 1,
color: '#808080'
}]
},
tooltip: {
formatter: function () {
return '<b>' + this.series.name + '</b><br/>' +
Highcharts.dateFormat('%Y-%m-%d %H:%M:%S', this.x) + '<br/>' +
Highcharts.numberFormat(this.y, 2);
}
},
legend: {
enabled: false
},
exporting: {
enabled: false
},
series: [{
name: 'Sensor data',
data: (function () {
// generate an array of sensor data
var data = [],
time = (new Date()).getTime(),
{% for item in t %}
data.push({
{% for i in 12 %}
{% if t.i == item %}
x: time + {{ i }} * 3000,
{% endif %}
{% endfor %}
y: {{ item }}
});
{% endfor %}
return data;
}())
}]
});
});
});
</script>
ctrl+u
<script type="text/javascript">
$(function () {
$(document).ready(function () {
Highcharts.setOptions({
global: {
useUTC: false
}
});
$('#container').highcharts({
chart: {
type: 'spline',
animation: Highcharts.svg, // don't animate in old IE
marginRight: 10,
events: {
load: function () {
// set up the updating of the chart each second
var series = this.series[0];
setInterval(function () {
var x = (new Date()).getTime(), // current time
y = ['23.125', '23.125', '23.125', '23.125', '23.125', '23.125', '23.125', '23.125', '23.125', '23.187', '23.125', '23.187'] ;
series.addPoint([x, y], true, true);
}, 3000);
}
}
},
title: {
text: 'Live temperature sensor values'
},
xAxis: {
type: 'datetime',
tickPixelInterval: 150
},
yAxis: {
title: {
text: 'Value'
},
plotLines: [{
value: 0,
width: 1,
color: '#808080'
}]
},
tooltip: {
formatter: function () {
return '<b>' + this.series.name + '</b><br/>' +
Highcharts.dateFormat('%Y-%m-%d %H:%M:%S', this.x) + '<br/>' +
Highcharts.numberFormat(this.y, 2);
}
},
legend: {
enabled: false
},
exporting: {
enabled: false
},
series: [{
name: 'Sensor data',
data: (function () {
// generate an array of sensor data
var data = [],
time = (new Date()).getTime(),
data.push({
x: time + 1 * 3000,
y: 23.125
});
data.push({
x: time + 2 * 3000,
y: 23.125
});
data.push({
x: time + 3 * 3000,
y: 23.125
});
data.push({
x: time + 4 * 3000,
y: 23.125
});
data.push({
x: time + 5 * 3000,
y: 23.125
});
data.push({
x: time + 6 * 3000,
y: 23.125
});
data.push({
x: time + 7 * 3000,
y: 23.125
});
data.push({
x: time + 8 * 3000,
y: 23.125
});
data.push({
x: time + 9 * 3000,
y: 23.125
});
data.push({
x: time + 10 * 3000,
y: 23.187
});
data.push({
x: time + 11 * 3000,
y: 23.125
});
data.push({
x: time + 12 * 3000,
y: 23.187
});
return data;
}())
}]
});
});
});
</script>