1👍
I don’t know what you mean by “it keeps refreshing the browser” – the update
method only updates the chart. It in no way should be refreshing the whole page.
But you can prevent animation when calling update
by passing 0
as the only parameter, as documented:
Sometimes when a chart updates, you may not want an animation. To achieve this you can call
update
with a duration of0
. This will render the chart synchronously and without an animation.
- [Chartjs]-How can I show chartjs datalabels only last bar?
- [Chartjs]-Chart JS Line Graph multitooltipkey background color issue
0👍
The answer is, the button was inside a form in the HTML, that why it was refreshing the whole page.
Wrong example:
<div class="chart1">
<canvas id="mychart1" ></canvas>
<form method="POST">
<p class="datafilter">Filtrar data:<input type="date" id="datafilter">
<button type="submit" id="subfilt">FILTRAR</button></p>
<button type="update" id="update" onclick="updateChart()">UPDATE</button>
</form>
</div>
Right example:
<div class="chart1">
<canvas id="mychart1" ></canvas>
<form method="POST">
<p class="datafilter">Filtrar data:<input type="date" id="datafilter">
<button type="submit" id="subfilt">FILTRAR</button></p>
</form>
<button type="update" id="update" onclick="updateChart()">UPDATE</button>
</div>
- [Chartjs]-ChartJS – Uncaught SyntaxError: Unexpected number
- [Chartjs]-Is there any way to display float bar in chart.js?
Source:stackexchange.com