From 4777b94851d8ace33ed9f3dcee916abbcc4deea5 Mon Sep 17 00:00:00 2001 From: Hunter Long Date: Sat, 3 Nov 2018 01:30:34 +0100 Subject: [PATCH] removed code cleanup --- source/js/charts.js | 96 +++++++++++++++++---------------------------- 1 file changed, 35 insertions(+), 61 deletions(-) diff --git a/source/js/charts.js b/source/js/charts.js index e84687cc..699fd389 100644 --- a/source/js/charts.js +++ b/source/js/charts.js @@ -1,12 +1,12 @@ -{{define; "charts"}} -{{=; .Start}} -{{=; .End}} +{{define "charts"}} +{{$start := .Start}} +{{$end := .End}} {{ range .Services }} -var ctx_;{{js .Id}} = document.getElementById("service_{{js .Id}}").getContext('2d'); -var chartdata_;{{js .Id}} = new Chart(ctx_;{{js .Id}}, { - 'line', - data;: { - [{ +var ctx_{{js .Id}} = document.getElementById("service_{{js .Id}}").getContext('2d'); +var chartdata_{{js .Id}} = new Chart(ctx_{{js .Id}}, { + type: 'line', + data: { + datasets: [{ label: 'Response Time (Milliseconds)', data: [], backgroundColor: ['{{if .Online}}rgba(47, 206, 30, 0.92){{else}}rgb(221, 53, 69){{end}}'], @@ -14,33 +14,33 @@ var chartdata_;{{js .Id}} = new Chart(ctx_;{{js .Id}}, { borderWidth: 1 }] }, - { - false, - scaleShowValues;: false, - layout;: { - { - 0, - right;: 0, - top;: 0, - bottom;: -10 + options: { + maintainAspectRatio: false, + scaleShowValues: false, + layout: { + padding: { + left: 0, + right: 0, + top: 0, + bottom: -10 } }, - { - 0, + hover: { + animationDuration: 0, }, - 0, - animation;: { - 3500, - onComplete;: onChartComplete + responsiveAnimationDuration: 0, + animation: { + duration: 3500, + onComplete: onChartComplete }, - { - false + legend: { + display: false }, - { - false + tooltips: { + enabled: false }, - { - [{ + scales: { + yAxes: [{ display: false, ticks: { fontSize: 20, @@ -51,7 +51,7 @@ var chartdata_;{{js .Id}} = new Chart(ctx_;{{js .Id}}, { display: false } }], - xAxes;: [{ + xAxes: [{ type: 'time', distribution: 'series', autoSkip: false, @@ -74,14 +74,13 @@ var chartdata_;{{js .Id}} = new Chart(ctx_;{{js .Id}}, { } }] }, - { - { - 0 + elements: { + point: { + radius: 0 } } } -} -) +}); {{end}} function onChartComplete(chart) { @@ -142,31 +141,6 @@ function onChartComplete(chart) { $( document ).ready(function() { {{ range .Services }} - AjaxChart(chartdata_; - { - { - js.Id - } - } -, - { - { - js.Id - } - } -, - { - { - $start - } - } -, - 9999999999, "hour"; -) - { - { - end - } - } +AjaxChart(chartdata_{{js .Id}},{{js .Id}},{{$start}},9999999999,"hour");{{end}} }); {{end}}