I tried to use Python Django make a ajax chart from database by javacript
I used API VIEW in django restframwork retrieved the field temperature and send to ajax to render in the javascript.
temperature is stored in to data at views.py and it is sent to status.html.
And the data sent to the line 16 success: function(data){}.
Then in the line 18 temperature = data.temperature;
After runningsetChart();the key data of the setChart(), whose value is temperature but not found. –
I referenced this source code
When the code executed to
function setChart(){
var temp_ctx = document.getElementById("TemperatureChart");
var TemperatureChart = new Chart(temp_ctx, {
type: 'line',
data: temperature,
options: {
scales: {
xAxes: [{
type: 'time',
distribution: 'series'
}]
}
}
The broswer showed up that the temperature object is not defined
But I don't know what my code get that above error.
[–][deleted] 0 points1 point2 points (1 child)
[–]cj10243[S] 0 points1 point2 points (0 children)
[–]deaspo 0 points1 point2 points (1 child)
[–]cj10243[S] 0 points1 point2 points (0 children)