misoproject / dataset

JavaScript library that makes managing the data behind client-side visualisations easy
http://misoproject.com
GNU General Public License v2.0
1.18k stars 99 forks source link

Groupby doesn't seem to work when the groupby column is an object #189

Closed xseignard closed 11 years ago

xseignard commented 11 years ago

Hello, I'm trying to group by a column that contains an object, and the result is a unique row.

Given the following code : https://github.com/xseignard/oddImmigration/blob/master/js/app.js

And the following data : https://github.com/xseignard/oddImmigration/blob/master/data/test.json

I'm trying to group by a column which is called geo which is an object.

But the result is only one row (we should have 2 rows), where everything is computed.

I tried the groupby with simple values and arrays and it works as expected.

Regards,

Xavier

iros commented 11 years ago

This is a result of the way JavaScript does its comparisons. I would recommend intercepting your data using the parse method and flattening the geo property into two properties: geo_id and geo_name. In practical terms, both are not necessary to uniquely identify a location.

xseignard commented 11 years ago

Thanks Irene, this is obvious for me now, since I understand js better! Thanks again.