function smartRound(precision, data) {
    for (var i = data.length, tolerance = +Math.pow(.1, precision).toFixed(precision); i--;) {
        if (data[i].toFixed(precision) != data[i]) {
            var rounded = +data[i].toFixed(precision - 1);
            data[i] = +Math.abs(rounded - data[i]).toFixed(precision + 1) >= tolerance ?
                +data[i].toFixed(precision) :
                rounded;
        }
    }
    return data;
}
Decrease accuracy of floating-point numbers
in transforms keeping a specified number of decimals.
Smart rounds values like 2.349 to 2.35.

@param {Number} fixed number of decimals
@param {Array} data input data array
@return {Array} output data array