mirror of
https://github.com/Luzifer/mondash.git
synced 2024-12-23 04:21:18 +00:00
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.
This commit is contained in:
parent
740ac28ce6
commit
e5da9e4c17
3 changed files with 22 additions and 2 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,2 +1,4 @@
|
|||
gin-bin
|
||||
mondash
|
||||
|
||||
*.sh
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -13,6 +13,20 @@
|
|||
<!-- Chartist Library -->
|
||||
<link rel="stylesheet" href="//cdn.jsdelivr.net/chartist.js/latest/chartist.min.css">
|
||||
<script src="//cdn.jsdelivr.net/chartist.js/latest/chartist.min.js"></script>
|
||||
<script>
|
||||
function timeConverter(UNIX_timestamp){
|
||||
var a = new Date(UNIX_timestamp*1000);
|
||||
var months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
|
||||
var year = a.getFullYear();
|
||||
var month = months[a.getMonth()];
|
||||
var date = a.getDate();
|
||||
var hour = a.getHours();
|
||||
var min = a.getMinutes();
|
||||
var sec = a.getSeconds();
|
||||
var time = date + ' ' + month + ' ' + year + ' ' + hour + ':' + min + ':' + sec ;
|
||||
return time;
|
||||
}
|
||||
</script>
|
||||
|
||||
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
|
||||
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
|
||||
|
@ -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);
|
||||
</script>
|
||||
<small>
|
||||
|
|
Loading…
Reference in a new issue