Skip to content
This repository was archived by the owner on Jun 9, 2020. It is now read-only.

Commit 0e744f8

Browse files
committed
_.values function for complex keys
1 parent 25a1bb3 commit 0e744f8

File tree

5 files changed

+31
-25
lines changed

5 files changed

+31
-25
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "crossfilter-universe",
3-
"version": "0.4.0",
3+
"version": "0.4.1",
44
"description": "The fastest way to query and explore multivariate datasets",
55
"main": "src/universe.js",
66
"directories": {

src/column.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ module.exports = function(service) {
8989
// Complex column Keys
9090
if (_.isArray(column.key)) {
9191
column.complex = true
92-
sample = _.map(_.pick(all[0], column.key))
92+
sample = _.values(_.pick(all[0], column.key))
9393
if (sample.length !== column.key.length) {
9494
throw new Error('Column key does not exist in data!', column.key)
9595
}
@@ -130,7 +130,10 @@ module.exports = function(service) {
130130
return Promise.resolve(column.dimension.bottom(Infinity))
131131
.then(function(rows) {
132132
var accessor = dimension.makeAccessor(column.key)
133-
if (column.type === 'array') {
133+
if (column.type === 'complex') {
134+
column.values = _.uniq(_.flatten(_.map(rows, accessor)))
135+
}
136+
else if (column.type === 'array') {
134137
column.values = _.uniq(_.flatten(_.map(rows, accessor)))
135138
} else {
136139
column.values = _.uniq(_.map(rows, accessor))

src/lodash.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ module.exports = {
2525
uniq: uniq,
2626
flatten: flatten,
2727
sort: sort,
28-
keys: keys,
28+
values: values,
2929
}
3030

3131

@@ -110,7 +110,7 @@ function map(a, b) {
110110
m = []
111111
for (key in a) {
112112
if (a.hasOwnProperty(key)) {
113-
m.push(a[key][b])
113+
m.push(a[key])
114114
}
115115
}
116116
return m
@@ -256,12 +256,12 @@ function sort(arr) {
256256
return arr;
257257
}
258258

259-
function keys(aa) {
260-
var keys = []
261-
for (var key in aa) {
262-
if (aa.hasOwnProperty(key)) {
263-
keys.push(aa[key])
259+
function values(a) {
260+
var values = []
261+
for (var key in a) {
262+
if (a.hasOwnProperty(key)) {
263+
values.push(a[key])
264264
}
265265
}
266-
return keys
266+
return values
267267
}

universe.js

Lines changed: 14 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

universe.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)