I have a django view and I'm expecting some of the data in the context to change a few times a second. Can I load a new context into the template after the response is sent without sending a new request? Thanks.
the view
def debug(request):
return render(request, 'all/debug.html', context={"x": x, "y": y})
the template
<div class="container">
<canvas id="data"></canvas>
<div class="graphing">
<select class="graph-select"></select>
<canvas id="graph" width="500"></canvas>
</div>
</div>
<script>
let y = "";
let x = ""
Chart.defaults.global.animation.duration = 0;
var ctx = document.getElementById('graph').getContext('2d');
var chart = new Chart(ctx, {
// The type of chart we want to create
type: 'line',
// The data for our dataset
data: {
labels: x.split` `.map(n => +n),
datasets: [{
label: 'My First dataset',
backgroundColor: 'rgb(255, 99, 132)',
borderColor: 'rgb(255, 99, 132)',
data: y.split` `.map(n => +n)
}]
},
// Configuration options go here
options: {
responsive: false,
}
});
</script>
What I want is to dynamically change the x and y data without sending a new request
Aucun commentaire:
Enregistrer un commentaire