src/charts/donut.js
function cleanData(data) {
            let dataWithPercentages;
            let cleanData = data.reduce((acc, d) => {
                // Skip data without quantity
                if (d[quantityLabel] === undefined || d[quantityLabel] === null) {
                    return acc;
                }

                d.quantity = +d[quantityLabel];
                d.name = String(d[nameLabel]);
                d.percentage = d[percentageLabel] || null;

                return [...acc, d];
            }, []);

            let totalQuantity = sumValues(cleanData);

            if (totalQuantity === 0 && emptyDataConfig.showEmptySlice) {
                isEmpty = true;
            }

            dataWithPercentages = cleanData.map((d) => {
                d.percentage = String(d.percentage || calculatePercent(d[quantityLabel], totalQuantity, percentageFormat));

                return d;
            });


            return dataWithPercentages;
        }
function cleanData(data) {
            let dataWithPercentages;
            let cleanData = data.reduce((acc, d) => {
                // Skip data without quantity
                if (d[quantityLabel] === undefined || d[quantityLabel] === null) {
                    return acc;
                }

                d.quantity = +d[quantityLabel];
                d.name = String(d[nameLabel]);
                d.percentage = d[percentageLabel] || null;

                return [...acc, d];
            }, []);

            let totalQuantity = sumValues(cleanData);

            if (totalQuantity === 0 && emptyDataConfig.showEmptySlice) {
                isEmpty = true;
            }

            dataWithPercentages = cleanData.map((d) => {
                d.percentage = String(d.percentage || calculatePercent(d[quantityLabel], totalQuantity, percentageFormat));

                return d;
            });


            return dataWithPercentages;
        }
function cleanData ( data ) { let dataWithPercentages ; let cleanData = data . reduce ( ( acc , d ) => { // Skip data without quantity if ( d [ quantityLabel ] === undefined || d [ quantityLabel ] === null ) { return acc ; } d . quantity = + d [ quantityLabel ] ; d . name = String ( d [ nameLabel ] ) ; d . percentage = d [ percentageLabel ] || null ; return [ ... acc , d ] ; } , [ ] ) ; let totalQuantity = sumValues ( cleanData ) ; if ( totalQuantity === 0 && emptyDataConfig . showEmptySlice ) { isEmpty = true ; } dataWithPercentages = cleanData . map ( ( d ) => { d . percentage = String ( d . percentage || calculatePercent ( d [ quantityLabel ] , totalQuantity , percentageFormat ) ) ; return d ; } ) ; return dataWithPercentages ; }
Cleaning data casting the quantities, names and percentages to the proper type while keeping
the rest of properties on the data. It also calculates the percentages if not present.
@param  {DonutChartData} data    Data as passed to the container
@return {DonutChartData}         Clean data with percentages
@private
Cleaning data casting the quantities names and percentages to the proper type while keeping the rest of properties on the data . It also calculates the percentages if not present .