diff --git a/toGraphTemplate.go b/toGraphTemplate.go index 58bf712..c4bc649 100644 --- a/toGraphTemplate.go +++ b/toGraphTemplate.go @@ -7,6 +7,28 @@ const graphTemplate = ` + + + {{.Title}} @@ -14,6 +36,8 @@ const graphTemplate = ` google.charts.load('current', {'packages':['annotationchart']}); google.charts.setOnLoadCallback(drawChart); + let chart; + function drawChart() { var data = new google.visualization.DataTable(); data.addColumn('date', 'Date'); @@ -32,7 +56,7 @@ const graphTemplate = ` {{- end}} ]); - var chart = new google.visualization.AnnotationChart(document.getElementById('chart_div')); + chart = new google.visualization.AnnotationChart(document.getElementById('chart_div')); var options = { displayAnnotations: true @@ -40,11 +64,29 @@ const graphTemplate = ` chart.draw(data, options); } + + function onChangeColumn(element) { + if (element.checked) { + chart.showDataColumns(element.value) + } else { + chart.hideDataColumns(element.value) + } + } -
+ + +
`