I'm using a d3.js Streamgraph to show sales over time. Then I've got a transition to show profit over the same period. The data looks like this:
var data = [{
    "name": "apples",
    "sales": [{
        "x": 0,
        "y": 941
    }, {
        "x": 1,
        "y": 490
    }],
    "profit": [{
        "x": 0,
        "y": 6
    }, {
        "x": 1,
        "y": 3
    }]
}, {
    "name": "oranges",
    "sales": [{
        "x": 0,
        "y": 344
    }, {
        "x": 1,
        "y": 425
    }],
    "profit": [{
        "x": 0,
        "y": 3
    }, {
        "x": 1,
        "y": 2
    }]
}];
It works, but I'm currently generating the stacked data in a somewhat ham-fisted way, applying stack.values twice:
var stack_sales = d3.layout.stack()
    .offset("wiggle")
    .values(function(d) { return d.sales; });
var stack_profit = d3.layout.stack()
    .offset("wiggle")
    .values(function(d) { return d.profit; });
stack_sales(data);
stack_profit(data);
I've been getting into JavaScript Patterns but can't see the DRY way to do this. Can you help?