tag:support.nodebox.net,2012-11-01:/discussions/nodebox-2-3/6029-trying-to-create-colored-stacked-barsNodeBox: Discussion 2020-04-14T20:17:56Ztag:support.nodebox.net,2012-11-01:Comment/452548222018-05-09T21:26:51Z2018-05-09T21:26:51ZTrying to create colored stacked bars<div><p>Hi Yannis,</p>
<p>You are making one stack per year and the segments in each year are proportional to the area value in your csv.</p>
<p>The basic trick is to make one stack at a time using a stack node (not a grid). You need a function which reads in a list of the all the data plus a value indicating the year of that particular stack. This function first filters the data to only rows from that year. Then, for each row, it makes a rectangle with a constant width and a height proportional to area. It then colors each rectangle and uses the stack node to stack them vertically from the bottom up (north). It will then output that stack packaged as a single group.</p>
<p>This function will spit out one stack for each year you feed into it. You can then use another stack node to arrange your year stacks horizontally (east) and an align node to make sure they all line up on the x axis. It is then easy to add labels for each stack.</p>
<p>I have created a NodeBox network that does exactly this. See zip file and screenshot. The "make_stack" function is a NodeBox subnetwork. Control click on it and choose Edit Children to open it up and see how it works.</p>
<p>Please let me know if this helps and don't be afraid to ask more questions!</p>
<p>John</p></div>johntag:support.nodebox.net,2012-11-01:Comment/452548222018-05-10T09:39:26Z2018-05-10T09:39:27ZTrying to create colored stacked bars<div><p>Thanks so much! This is all I needed for now. :)</p></div>Yannis