Skip to content

Commit 6084bde

Browse files
committed
Merge pull request #29 into dev
Resolves #29
2 parents f113bfc + c46f47a commit 6084bde

File tree

5 files changed

+45
-33
lines changed

5 files changed

+45
-33
lines changed

scout-ui/src/minicharts/d3fns/date.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ module.exports = function(opts) {
5858
return {
5959
label: weekdayLabels[i],
6060
value: d.length,
61-
tooltip: weekdayLabels[i]
61+
// tooltip: weekdayLabels[i]
6262
};
6363
})
6464
.value();
@@ -74,7 +74,7 @@ module.exports = function(opts) {
7474
return {
7575
label: hourLabels[i] + ':00',
7676
value: d.length,
77-
tooltip: hourLabels[i] + ':00'
77+
// tooltip: hourLabels[i] + ':00'
7878
};
7979
})
8080
.value();

scout-ui/src/minicharts/d3fns/few.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,7 @@ module.exports = function(data, g, width, height, options) {
6060
.attr('width', function(d) {
6161
return x(d.value);
6262
})
63-
.attr('height', barHeight)
64-
.on('mouseover', tip.show)
65-
.on('mouseout', tip.hide);
63+
.attr('height', barHeight);
6664

6765
bar.append('text')
6866
.attr('y', barHeight / 2)
@@ -74,4 +72,15 @@ module.exports = function(data, g, width, height, options) {
7472
})
7573
.attr('fill', 'white');
7674

75+
bar.append('rect')
76+
.attr('class', 'glass')
77+
.attr('y', 0)
78+
.attr('x', 0)
79+
.attr('width', function(d) {
80+
return x(d.value);
81+
})
82+
.attr('height', barHeight)
83+
.on('mouseover', tip.show)
84+
.on('mouseout', tip.hide);
85+
7786
};

scout-ui/src/minicharts/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ module.exports = AmpersandView.extend({
2828

2929
// unique values get a div-based minichart
3030
if ((this.model._id === 'String') &&
31-
(_.uniq(this.model.values.toJSON()).length === this.model.count)) {
31+
(this.model.unique === this.model.count)) {
3232

3333
this.viewOptions.renderMode = 'html';
3434
this.viewOptions.className = 'minichart unique';

scout-ui/src/minicharts/unique.jade

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ div(data-hook='viz-container')
55
//- = minValue
66
77
dt
8-
//-a(href="#")
9-
i.mms-icon-continuous(data-hook='refresh')
8+
a
9+
i.mms-icon-continuous(data-hook='refresh')
1010
dd
1111
ul.list-inline
1212
each val in randomValues

scout-ui/src/minicharts/unique.js

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,45 +3,48 @@ var _ = require('lodash');
33
var debug = require('debug')('scout-ui:minicharts:unique');
44

55
module.exports = VizView.extend({
6+
props: {
7+
timer: {
8+
type: 'number',
9+
default: null
10+
}
11+
},
612
template: require('./unique.jade'),
713
derived: {
8-
orderedValues: {
9-
deps: ['model.values'],
10-
cache: true,
11-
fn: function() {
12-
return this.model.values.toJSON().sort();
13-
}
14-
},
15-
minValue: {
16-
deps: ['orderedValues'],
17-
cache: true,
18-
fn: function() {
19-
return this.orderedValues[0];
20-
}
21-
},
22-
maxValue: {
23-
deps: ['orderedValues'],
24-
cache: true,
25-
fn: function() {
26-
return this.orderedValues[this.orderedValues.length - 1];
27-
}
28-
},
2914
randomValues: {
3015
deps: ['orderedValues'],
3116
cache: false,
3217
fn: function() {
33-
return this.orderedValues.slice(1, 15);
18+
return _(this.model.values.sample(15))
19+
.map(function(x) {
20+
return x.value;
21+
})
22+
.value();
3423
}
3524
}
3625
},
3726
events: {
38-
'click .fa-refresh': 'refresh'
27+
'mousedown [data-hook=refresh]': 'refresh',
28+
'mouseup': 'stopTimer'
3929
},
4030
render: function() {
4131
this.renderWithTemplate(this);
4232
},
43-
refresh: function() {
44-
debug('refresh clicked');
33+
refresh: function(event) {
34+
if (!this.timer) {
35+
this.timer = setInterval(this.refresh.bind(this), 600);
36+
} else {
37+
clearInterval(this.timer);
38+
this.timer = setInterval(this.refresh.bind(this), 50);
39+
}
40+
if (event) {
41+
event.preventDefault();
42+
}
43+
this.render();
44+
},
45+
stopTimer: function(event) {
46+
clearInterval(this.timer);
47+
this.timer = null;
4548
}
4649

4750
});

0 commit comments

Comments
 (0)