Add link on graph

This commit is contained in:
Mickael 2019-09-16 19:43:07 +02:00
parent 92aa01709a
commit 7878974929

View file

@ -22,7 +22,7 @@ $(document).ready(function () {
}); });
function graphDisplay(ctx, data, title) { function graphDisplay(ctx, data, title) {
new Chart(ctx, { var myChart = new Chart(ctx, {
// The type of chart we want to create // The type of chart we want to create
type: 'bar', type: 'bar',
@ -53,6 +53,14 @@ function graphDisplay(ctx, data, title) {
stepSize: 500 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);
}
} }
} }
}); });