-
Notifications
You must be signed in to change notification settings - Fork 15
/
aggregatedMiners.js
49 lines (43 loc) · 1.55 KB
/
aggregatedMiners.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
'use strict';
var _ = require('lodash'),
hashrateHelper = require('../handlebars/helpers/hashrate'),
renderHistoricalDataGraph = require('./mixins/renderHistoricalDataGraph'),
View = require('../View');
module.exports = View.extend({
postRender: function () {
var self = this,
colors = [ '#cae2f7', '#a7d2f7' ],
series,
graphMixin;
if (self.graph === undefined) {
series = _(self.module.get('historicalData'))
.map(function (val) {
return _(val)
.keys()
.filter(function (key) { return key.split('.')[0] === 'currentHashrate'; })
.map(function (key) { return key.split('.')[1]; })
.value();
})
.flatten()
.unique()
.map(function (minerId, it) {
return {
attr: 'currentHashrate.' + minerId,
name: self.module.get('minerTitles')[minerId],
color: colors[it % colors.length]
};
})
.value();
graphMixin = renderHistoricalDataGraph(series, '.graph', {
stack: true
}, {
yFormatter: function (value) {
return hashrateHelper(value);
}
});
_.extend(this, graphMixin);
this.postRender();
}
},
template: 'aggregatedMiners'
});