implement on click to round

This commit is contained in:
Yannik Schmidt
2020-09-30 08:04:50 +02:00
parent d4d240508f
commit 4c486e57a3

View File

@@ -32,8 +32,9 @@
</div> </div>
{% include 'footer.html' %} {% include 'footer.html' %}
<script defer> <script defer>
var canvas = document.getElementById("lineChart").getContext('2d'); var canvas = document.getElementById("lineChart")
var historicalRank = new Chart(canvas, { var ctx = canvas.getContext('2d');
var historicalRank = new Chart(ctx, {
type: 'line', type: 'line',
data: { data: {
labels: [ {{ CSV_MONTH_YEAR_OF_RATINGS | safe }} ], labels: [ {{ CSV_MONTH_YEAR_OF_RATINGS | safe }} ],
@@ -44,7 +45,7 @@
borderColor: [ 'rgba(200, 99, 132, .7)' ], borderColor: [ 'rgba(200, 99, 132, .7)' ],
borderWidth: 2 borderWidth: 2
}], }],
}, },
options: { options: {
scales: { scales: {
yAxes: [{ yAxes: [{
@@ -75,6 +76,16 @@
responsive: true responsive: true
} }
}); });
var datasetHelper = {{ CSV_TIMESTAMPS | safe }}
canvas.onclick = function (evt) {
var points = historicalRank.getElementsAtEvent(evt);
if(points.length != 1){
return
}
var timestampMs = datasetHelper[points[0]._index] / 1000
var idString = timestampMs.toString()
window.location.href = "/round-info?id=" + idString
};
</script> </script>
</body> </body>
</html> </html>