Graphics Programs Reference
In-Depth Information
Luckily, it's easy. The year column is the same, so you just need to change
any people references to expenditure (vertical axis) and any occupation
references to category (the layers). Finally, remove all uses of gender.
At line 74 the data is reshaped and prepared for the stacked area chart. It
specifies by occupation and sex as the categories (that is, layers) and uses
year on the x-axis and people on the y-axis.
There's some
great open-source
work going on in
visualization, and
although coding
can seem daunting
in the beginning,
many times you
can use existing
code with your
own data just by
changing variables.
The challenge is
reading the code
and figuring out
how everything
works.
var dr:Array = reshape(ds.nodes.data, [“occupation”,”sex”],
“year”, “people”, _cols);
Change it to this:
var dr:Array = reshape(ds.nodes.data, [“category”],
“year”, “expenditure”, _cols);
You only have one category (sans sex), and that's uh, category. The x-axis
is still year, and the y-axis is expenditure.
Line 84 sorts the data by occupation (alphabetically) and then sex (numeri-
cally). Now just sort by category:
data.nodes.sortBy(“data.category”);
Are you starting to get the idea here? Mostly everything is laid out for you.
You just need to adjust the variables to accommodate the data.
Line 92 colors layers by sex, but you don't have that split in the data, so you
don't need to do that. Remove the entire row:
data.nodes.setProperty(“fillHue”, iff(eq(“data.sex”,1), 0.7, 0));
We'll come back to customizing the colors of the stacks a little later.
Line 103 adds labels based occupation:
_vis.operators.add(new StackedAreaLabeler(“data.occupation”));
You want to label based on spending category, so change the line
accordingly:
_vis.operators.add(new StackedAreaLabeler(“data.category”));
Lines 213-231 handle filtering in JobVoyager. First, there's the male/
female filter; then there's the filter by occupation. You don't need the for-
mer, so you can get rid of lines 215-218 and then make line 219 a plain if
statement.
Search WWH ::




Custom Search