src/charts/stacked-area.js
function buildLayers() {
            dataByDateFormatted = dataByDate
                .map(d => assign({}, d, d.values))
                .map(d => {
                    Object.keys(d).forEach(k => {
                        const entry = d[k];

                        if (entry && entry.name) {
                            d[entry.name] = entry.value;
                        }
                    });

                    return assign({}, d, {
                        date: new Date(d['key'])
                    });
                });

            dataByDateZeroed = dataByDate
                .map(d => assign({}, d, d.values))
                .map(d => {
                    Object.keys(d).forEach(k => {
                        const entry = d[k];

                        if (entry && entry.name) {
                            d[entry.name] = 0;
                        }
                    });

                    return assign({}, d, {
                        date: new Date(d['key'])
                    });
                });

            let initialTotalsObject = uniq(data.map(getName))
                                        .reduce((memo, key) => (
                                            assign({}, memo, {[key]: 0})
                                        ), {});

            let totals = data
                .reduce((memo, item) => (
                    assign({}, memo, {[item.name]: memo[item.name] += item.value})
                ), initialTotalsObject);

            order = topicsOrder || formatOrder(totals);

            let stack3 = d3Shape.stack()
                .keys(order)
                .order(d3Shape.stackOrderNone)
                .offset(d3Shape.stackOffsetNone);

            layersInitial = stack3(dataByDateZeroed);
            layers = stack3(dataByDateFormatted);
        }
function buildLayers() {
            dataByDateFormatted = dataByDate
                .map(d => assign({}, d, d.values))
                .map(d => {
                    Object.keys(d).forEach(k => {
                        const entry = d[k];

                        if (entry && entry.name) {
                            d[entry.name] = entry.value;
                        }
                    });

                    return assign({}, d, {
                        date: new Date(d['key'])
                    });
                });

            dataByDateZeroed = dataByDate
                .map(d => assign({}, d, d.values))
                .map(d => {
                    Object.keys(d).forEach(k => {
                        const entry = d[k];

                        if (entry && entry.name) {
                            d[entry.name] = 0;
                        }
                    });

                    return assign({}, d, {
                        date: new Date(d['key'])
                    });
                });

            let initialTotalsObject = uniq(data.map(getName))
                                        .reduce((memo, key) => (
                                            assign({}, memo, {[key]: 0})
                                        ), {});

            let totals = data
                .reduce((memo, item) => (
                    assign({}, memo, {[item.name]: memo[item.name] += item.value})
                ), initialTotalsObject);

            order = topicsOrder || formatOrder(totals);

            let stack3 = d3Shape.stack()
                .keys(order)
                .order(d3Shape.stackOrderNone)
                .offset(d3Shape.stackOffsetNone);

            layersInitial = stack3(dataByDateZeroed);
            layers = stack3(dataByDateFormatted);
        }
function buildLayers ( ) { dataByDateFormatted = dataByDate . map ( d => assign ( { } , d , d . values ) ) . map ( d => { Object . keys ( d ) . forEach ( k => { const entry = d [ k ] ; if ( entry && entry . name ) { d [ entry . name ] = entry . value ; } } ) ; return assign ( { } , d , { date : new Date ( d [ 'key' ] ) } ) ; } ) ; dataByDateZeroed = dataByDate . map ( d => assign ( { } , d , d . values ) ) . map ( d => { Object . keys ( d ) . forEach ( k => { const entry = d [ k ] ; if ( entry && entry . name ) { d [ entry . name ] = 0 ; } } ) ; return assign ( { } , d , { date : new Date ( d [ 'key' ] ) } ) ; } ) ; let initialTotalsObject = uniq ( data . map ( getName ) ) . reduce ( ( memo , key ) => ( assign ( { } , memo , { [ key ] : 0 } ) ) , { } ) ; let totals = data . reduce ( ( memo , item ) => ( assign ( { } , memo , { [ item . name ] : memo [ item . name ] += item . value } ) ) , initialTotalsObject ) ; order = topicsOrder || formatOrder ( totals ) ; let stack3 = d3Shape . stack ( ) . keys ( order ) . order ( d3Shape . stackOrderNone ) . offset ( d3Shape . stackOffsetNone ) ; layersInitial = stack3 ( dataByDateZeroed ) ; layers = stack3 ( dataByDateFormatted ) ; }
Builds the stacked layers layout
@return {D3Layout} Layout for drawing the chart
@private
Builds the stacked layers layout