Skip to content

Commit 4b8f8ed

Browse files
rueckstiesskangas
authored andcommitted
unique charts now show actually random values from the sample set.
1 parent 209dc03 commit 4b8f8ed

File tree

1 file changed

+6
-22
lines changed

1 file changed

+6
-22
lines changed

scout-ui/src/minicharts/unique.js

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,16 @@ var debug = require('debug')('scout-ui:minicharts:unique');
55
module.exports = VizView.extend({
66
template: require('./unique.jade'),
77
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-
},
298
randomValues: {
309
deps: ['orderedValues'],
3110
cache: false,
3211
fn: function() {
33-
return this.orderedValues.slice(1, 15);
12+
return _(this.model.values.sample(15))
13+
.map(function(x) {
14+
return x.value;
15+
})
16+
.sort()
17+
.value();
3418
}
3519
}
3620
},

0 commit comments

Comments
 (0)