From e5da9e4c17d442a9e3b3005c96e69afbd95b8bbd Mon Sep 17 00:00:00 2001 From: zainhoda Date: Sun, 22 Feb 2015 16:19:26 -0500 Subject: [PATCH] Additional fixes for graphing Historical data should be appended at the end of the list. Add some Javascript code to convert time in int to time in string. --- .gitignore | 2 ++ structs.go | 4 ++-- templates/dashboard.html | 18 ++++++++++++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 9b10a1b..cfc5a8c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ gin-bin mondash + +*.sh diff --git a/structs.go b/structs.go index ea9d295..df78bbd 100644 --- a/structs.go +++ b/structs.go @@ -120,11 +120,11 @@ func (dm *dashboardMetric) Update(m *dashboardMetric) { if m.Freshness != 0 { dm.Freshness = m.Freshness } - dm.HistoricalData = append(dashboardMetricHistory{dashboardMetricStatus{ + dm.HistoricalData = append(dm.HistoricalData, dashboardMetricStatus{ Time: time.Now(), Status: m.Status, Value: m.Value, - }}, dm.HistoricalData...) + }) countStatus := make(map[string]float64) diff --git a/templates/dashboard.html b/templates/dashboard.html index f6c51c2..90414e5 100644 --- a/templates/dashboard.html +++ b/templates/dashboard.html @@ -13,6 +13,20 @@ + @@ -91,6 +105,10 @@ ] }; + for (var i = 0; i < data.labels.length; i++) { + data.labels[i] = timeConverter(data.labels[i]); + } + new Chartist.Line('.{{metric.MetricID}}', data);