function buildDataArrayForStackedBarChart(retrievedData, subCategoryNames) {
        console.log("%cbuildDataArrayForStackedBarChart function called!", "color:DarkGreen; font-weight: bold");
        console.log("data array:");
        console.table(retrievedData);

        var dataToDrawStackedBars = [];

        //Add new array of objects to each row of retrievedData array
        // with start and end  values for each bar segment
        retrievedData.forEach(function (d) {
            console.log("%c=================================================", "color:Purple; font-weight: bold; font-size: large")

            var y0 = 0,
               subCategory_Value,
               subCategory_Start = 0,
               subCategory_End,
               newStackedBarDataArrayItem = [];

            //Add a new property to the data array that will itself be an array:
            //the stackedBarData array in the format d3 wants
            d.stackedBarData = subCategoryNames.map(function (subCategory_Name) {
                // d.stackedBarData = colorScalingFunction.domain().map(function (subCategory_Name) {

                //Get the value for this bar segment
                subCategory_Value = +d[subCategory_Name];
                subCategory_End = subCategory_Start + subCategory_Value;
                console.log("%csubCategory Name: " + subCategory_Name, "color:Purple; font-weight: bold; font-size: larger");
                console.log("subCategory_Start = " + subCategory_Start + "    " +
                             "subCategory_End = " + subCategory_End);

                newStackedBarDataArrayItem = {
                    name: subCategory_Name,
                    y0: subCategory_Start,
                    y1: subCategory_End
                };
                console.log(newStackedBarDataArrayItem);
                console.log(" ");

                //Move starting y position to old ending y position
                subCategory_Start = subCategory_Start + subCategory_Value;

                return newStackedBarDataArrayItem;

            }); //end of loop through a row of the retrievedData array

            console.table(d.stackedBarData);

            //The total sum of all the y values for this row
            d.rowTotal = d.stackedBarData[d.stackedBarData.length - 1].y1;
            console.log("d.rowTotal = " + d.rowTotal);

        });

        //Sort by total, so bar chart goes from largest to smallest
        retrievedData.sort(function (a, b) { return b.rowTotal - a.rowTotal; });

        console.log("Modified Data Array:")
        console.table(retrievedData);

        return retrievedData;
    }
// note:  YOU SHOULDN'T CHANGE ANY CODE IN THIS FUNCTION!!

YOU SHOULDN'T CHANGE ANY CODE IN THIS FUNCTION
YOU SHOULDN ' T CHANGE ANY CODE IN THIS FUNCTION
function buildDataArrayForStackedBarChart(retrievedData, subCategoryNames) {
        console.log("%cbuildDataArrayForStackedBarChart function called!", "color:DarkGreen; font-weight: bold");
        console.log("data array:");
        console.table(retrievedData);
        var dataToDrawStackedBars = [];
        retrievedData.forEach(function (d) {
            console.log("%c=================================================", "color:Purple; font-weight: bold; font-size: large")
            var y0 = 0,
               subCategory_Value,
               subCategory_Start = 0,
               subCategory_End,
               newStackedBarDataArrayItem = [];
            d.stackedBarData = subCategoryNames.map(function (subCategory_Name) {
                subCategory_Value = +d[subCategory_Name];
                subCategory_End = subCategory_Start + subCategory_Value;
                console.log("%csubCategory Name: " + subCategory_Name, "color:Purple; font-weight: bold; font-size: larger");
                console.log("subCategory_Start = " + subCategory_Start + "    " +
                             "subCategory_End = " + subCategory_End);
                newStackedBarDataArrayItem = {
                    name: subCategory_Name,
                    y0: subCategory_Start,
                    y1: subCategory_End
                };
                console.log(newStackedBarDataArrayItem);
                console.log(" ");
                subCategory_Start = subCategory_Start + subCategory_Value;
                return newStackedBarDataArrayItem;
            }); 
            console.table(d.stackedBarData);
            d.rowTotal = d.stackedBarData[d.stackedBarData.length - 1].y1;
            console.log("d.rowTotal = " + d.rowTotal);
        });
        retrievedData.sort(function (a, b) { return b.rowTotal - a.rowTotal; });
        console.log("Modified Data Array:")
        console.table(retrievedData);
        return retrievedData;
    }
function buildDataArrayForStackedBarChart ( retrievedData , subCategoryNames ) { console . log ( "%cbuildDataArrayForStackedBarChart function called!" , "color:DarkGreen; font-weight: bold" ) ; console . log ( "data array:" ) ; console . table ( retrievedData ) ; var dataToDrawStackedBars = [ ] ; retrievedData . forEach ( function ( d ) { console . log ( "%c=================================================" , "color:Purple; font-weight: bold; font-size: large" ) var y0 = 0 , subCategory_Value , subCategory_Start = 0 , subCategory_End , newStackedBarDataArrayItem = [ ] ; d . stackedBarData = subCategoryNames . map ( function ( subCategory_Name ) { subCategory_Value = + d [ subCategory_Name ] ; subCategory_End = subCategory_Start + subCategory_Value ; console . log ( "%csubCategory Name: " + subCategory_Name , "color:Purple; font-weight: bold; font-size: larger" ) ; console . log ( "subCategory_Start = " + subCategory_Start + "    " + "subCategory_End = " + subCategory_End ) ; newStackedBarDataArrayItem = { name : subCategory_Name , y0 : subCategory_Start , y1 : subCategory_End } ; console . log ( newStackedBarDataArrayItem ) ; console . log ( " " ) ; subCategory_Start = subCategory_Start + subCategory_Value ; return newStackedBarDataArrayItem ; } ) ; console . table ( d . stackedBarData ) ; d . rowTotal = d . stackedBarData [ d . stackedBarData . length - 1 ] . y1 ; console . log ( "d.rowTotal = " + d . rowTotal ) ; } ) ; retrievedData . sort ( function ( a , b ) { return b . rowTotal - a . rowTotal ; } ) ; console . log ( "Modified Data Array:" ) console . table ( retrievedData ) ; return retrievedData ; }
note:  YOU SHOULDN'T CHANGE ANY CODE IN THIS FUNCTION!
note : YOU SHOULDN ' T CHANGE ANY CODE IN THIS FUNCTION!
//Add new array of objects to each row of retrievedData array
 // with start and end  values for each bar segment
 //Add a new property to the data array that will itself be an array:
 //the stackedBarData array in the format d3 wants
 // d.stackedBarData = colorScalingFunction.domain().map(function (subCategory_Name) {
 //Get the value for this bar segment
 //Move starting y position to old ending y position
 //end of loop through a row of the retrievedData array
 //The total sum of all the y values for this row
 //Sort by total, so bar chart goes from largest to smallest
