Slice and Dice TreeMap using iterators

Swiftlikeninja's picture

I built a slice and dice treemap in quartz that staticly supports 8 values and will graphically represent the data in ratios of individual value over collective total. What I would like to do now is repurpose the code to use an iterator that would step through a structure of values and generate the treemap instead of having to hardcode each and every member. The problem Im running into is the position of the bars is dependent of the previous block formula results. Im at a lost as to where to continue, Ive attached the treemap qtz. If anyone could assist and push me in the right direction, I would be greatly appreciative.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Swiftlikeninja's picture
Re: Slice and Dice TreeMap using iterators

I forgot to add the Qtz, sorry for the quick edit

treemapexample.qtz26.64 KB's picture
Re: Slice and Dice TreeMap using iterators

Seeing as 228 is a lucky number I've done your homework for you ;-)

You need to
1. sort + total the data set

In a loop of some kind,
2. subtotal preceding values for each item
3. calculate width for each item based current value
4. calculate starting position for each item based on subtotal of previous values

I choose to do it in JS because its cleaner to me but make a queue of math patches and do the same if you like.

The first JS patch generates the Data Set. The second JS patch generates the information. It is normalised data in the range of values for X [0,1]. This allows you to map it to whatever screen positions you want in the iterator that displays it all.

treemapexample ii.qtz45.66 KB

mattgolsen's picture
Re: Slice and Dice TreeMap using iterators

Has anyone attempted a squarified version of this? I attempted, but couldn't quite wrap my head around it.