add reload option on graph

This commit is contained in:
Simon Vieille 2020-04-01 21:01:25 +02:00
parent aa9c2422ae
commit 71a54c943f
Signed by: deblan
GPG key ID: 03383D15A1D31745
2 changed files with 8 additions and 3 deletions

View file

@ -40,9 +40,14 @@ var ChartLoader = function() {
instance.resize(); instance.resize();
}); });
} }
if (chart.hasAttribute('data-reload')) {
window.setTimeout(function() {
chart.dispatchEvent(new Event('refresh'));
}, chart.getAttribute('data-reload'))
}
}); });
}); });
chart.dispatchEvent(new Event('refresh')); chart.dispatchEvent(new Event('refresh'));
}); });
} }

View file

@ -7,7 +7,7 @@
<div class="title is-4">Température</div> <div class="title is-4">Température</div>
<div class="box"> <div class="box">
<div class="chart-container" data-api="{{ path('api_monitoring_temperature') }}" data-type="line"> <div class="chart-container" data-reload="300000" data-api="{{ path('api_monitoring_temperature') }}" data-type="line">
<canvas class="chart-canvas" id="chart-temperature"></canvas> <canvas class="chart-canvas" id="chart-temperature"></canvas>
</div> </div>
</div> </div>
@ -15,7 +15,7 @@
<div class="title is-4">Hygrométrie</div> <div class="title is-4">Hygrométrie</div>
<div class="box"> <div class="box">
<div class="chart-container" data-api="{{ path('api_monitoring_hygrometry') }}" data-type="line"> <div class="chart-container" data-reload="300000" data-api="{{ path('api_monitoring_hygrometry') }}" data-type="line">
<canvas class="chart-canvas" id="chart-hygrometry"></canvas> <canvas class="chart-canvas" id="chart-hygrometry"></canvas>
</div> </div>
</div> </div>