Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON Format #171

Open
Borreguin opened this issue Nov 2, 2016 · 1 comment
Open

JSON Format #171

Borreguin opened this issue Nov 2, 2016 · 1 comment

Comments

@Borreguin
Copy link

I would like to know if this format is compatible with the crossfilter:
{"timestamp": ["2013-11-01 00:00:00", "2013-11-01 01:00:00", "2013-11-01 02:00:00", *...], "V1": [24, 24.7, 24.2, *... ], "V2": [511.32, 509.7, 507.3, ...], "V3": [26.1, 26.1, 26.2, *... ]}
*... -> it continues (larger data)

If I send my data in this way I'm able to send more values in compact way instead to use:
{{"timestamp": "2013-06-01,'V1': 25.5, 'V2': 52.6 }, {"timestamp": "2013-06-02,'V1': 25.5, 'V2': 52.6 }} , etc

Could you suggest me something about? (by he way in the first format, the data is order by time)

Thanks,
Roberto

@gordonwoodhull
Copy link

gordonwoodhull commented Nov 3, 2016

Stack Overflow is a better place for asking support questions.

But yes, you can use data like this. Just supply an array of indices as your data to crossfilter. Then write your dimension and group accessors to use the index to fetch data from the original arrays.

Something like:

var N = data.timestamp.length;
var r = _.range(N); // [0,1,2,...,N-1]
var ndx = crossfilter(r);
var V1dim = ndx.dimension(function(d) { return data.V1[d]; });
var sumV2perV1 = V1dim.group().reduceSum(function(d) { return data.V2[d];});

Downside is that you won't find a lot of examples of people using crossfilter this way, so you'll have to translate everything. It might be easier to send your data over the wire as object of arrays, and then rotate it into an array of objects in JavaScript, and probably not too expensive unless your data is huge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants