Using dimensions with arrays in dc.js/crossfilter
Asked Answered
S

1

6

Crossfilter supports dimensions with arrays since version 1.4.0-alpha.06 https://github.com/crossfilter/crossfilter/wiki/API-Reference#dimension_with_arrays

Is it possible to exploit this functionality in dc.js?

I haven' found any examples yet... I am aware of the method described in Is there a way to tell crossfilter to treat elements of array as separate records instead of treating whole array as single key?, but that works with earlier versions of crossfilter too (it does not make use of the new functionality).

Spindrift answered 18/1, 2017 at 13:14 Comment(4)
Yes, it's possible. :) Would you care to contribute an example?Iniquity
The cool thing about this is that you just use one of these array dimensions and it should work the same way as any other dimension in dc.js. I think...Bienne
P.S. I edited the version mentioned, as this functionality has not (and I assume will not) be introduced in the 1.3.x line.Bienne
Thanks, the crossfilter version I was testing was the issue... using 1.4.0 it is possible to get something going on with pies and rows. I'll post an answer with a working example.Spindrift
S
10

With help from comments above, I managed to get this working, very simple indeed if you use the right version of crossfilter (1.4.0). Works fine with rowChart() and pieChart().

I made a an example bl.ock based on previous approaches: http://bl.ocks.org/emiguevara/4bd152a8828f6b31270702d97dc0133d

Spindrift answered 19/1, 2017 at 12:27 Comment(2)
Brilliant great for multipart survey questions. Thank you!Clout
How to create bar chart if the data set look like this {"key":"KEY-1", "state":"CA", "topics":["Technology","Science", "Automotive"],"medium":["paper", "web"], "date":new Date("10/02/2012"),"publication":[{at:new Date("10/05/2012"),publication_name:"MixMe"},{at:new Date("10/05/2013"),publication_name:"MC GRAW"},]}, { "key":"KEY-2","state":"CA","topics":["Health"],"medium":["paper"],"date": new Date("10/05/2012"),"publication":[{at:new Date("10/05/2010"),publication_name:"Come On"},{at:new Date("10/05/2011"),publication_name:"MC GRAW"},]. Count on y-axis and publication name on x axisTimeous

© 2022 - 2024 — McMap. All rights reserved.