From 7878974929e19fec5044e877488f3c14863f90a0 Mon Sep 17 00:00:00 2001 From: Mickael Date: Mon, 16 Sep 2019 19:43:07 +0200 Subject: [PATCH] Add link on graph --- site/coastats.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/site/coastats.js b/site/coastats.js index 2518956..12e8150 100644 --- a/site/coastats.js +++ b/site/coastats.js @@ -22,7 +22,7 @@ $(document).ready(function () { }); function graphDisplay(ctx, data, title) { - new Chart(ctx, { + var myChart = new Chart(ctx, { // The type of chart we want to create type: 'bar', @@ -53,6 +53,14 @@ function graphDisplay(ctx, data, title) { stepSize: 500 } }] + }, + onClick: function (evt, elem) { + var firstPoint = myChart.getElementAtEvent(evt)[0]; + + if (firstPoint) { + var label = myChart.data.datasets[firstPoint._datasetIndex].label; + window.open("https://coa.crapaud-fou.org/channel/"+label); + } } } });