-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Add treemap [WIP] #1034
base: master
Are you sure you want to change the base?
Add treemap [WIP] #1034
Conversation
Is it possible for you to share a sample json that can be used to create this nested treemap. |
I don't think it particularly matters what the JSON looks like, but you'll need to figure out a way to get it into Crossfilter (which handles flat rows). I typically pass CSV from the server, so here's an example of what hierarchical data may look like:
This data is a flattened hierarchy as each row is made of multiple key columns (namely
It is likely more performant to return an object literal from the dimension accessor as was tested here. When constructing the chart, it will need to know how to parse these keys. The
A disclaimer, I haven't tried any of the above as I don't use Crossfilter. In theory, this should work though. |
What i have currently is a TopiClusterId(number) and a list of words in that Cluster with frequency for each of them. Not sure how i would be able to create a json for this. |
Something like:
Then with Crossfilter and dc:
|
But this would not allow me group all the words with the same cluster(esp Color). |
It would if each record in the JSON dataset had the same value (string coerced) for a particular key (such as "TopicCLusterId"). The code transforms the flat structure into a hierarchy using d3.nest and accumulates a color/size score based on some measurable features of the data (such as frequency). You could easily convert something like:
into a flat list structure if this is what you have. Something like
|
I have tried using the sample you provided. I still get Data[Object][Object]. |
Can you share a JSFiddle? |
@GunjanSh I've updated the code with a bug fix to handle Crossfilter a bit better. I've also added an example HTML page you can use to try it out. |
Thanks for sharing the files. In order to allow Treemap for cross filter,i was trying to use the code you provided(supported by DC). Thank you! |
@mtraynham excellent work. Wrote out a whole question for you regarding how to get this to work with no hierarchy - i.e. with one keyAccessor instead of two as in the example, but managed to answer it myself. Thank you! |
Trying to find the solution how to use dimension with array value for treemap. Appreciate any help https://stackoverflow.com/questions/44338307/using-dimensions-with-arrays-in-dc-js-for-treemap |
This is a bit different from the other charts since it represents a hierarchy. Most of the motivation was driven from one of Bostock's examples. I haven't actually tried this with Crossfilter yet, so I'm not sure how it will work with the filtering... I imagine a new filter type may have to be introduced...
Anyways, the
keyAccessor
is not a single functor, but an array of functors providing the necessary keys on each datum at every level. ThevalueAccessor
andcolorAccessor
pull the metric values from each datum as normal, but respectively, there is asizeAggregator
andcolorAggregator
function to accumulate these leave values to each parent node.I'll provide a picture tomorrow, but it looks almost very similar to Bostock's version (I just productized it for the most part).
Resolves #129
TODO