From 15072aaa22bf18819e976c864490b85b5afd7c30 Mon Sep 17 00:00:00 2001 From: Shahid Date: Thu, 2 Nov 2017 17:00:24 +0500 Subject: [PATCH 1/2] add ES6 implementation of a shuffle function --- src/scripts/helpers/utils.js | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/src/scripts/helpers/utils.js b/src/scripts/helpers/utils.js index 3e77173..d30ec5e 100644 --- a/src/scripts/helpers/utils.js +++ b/src/scripts/helpers/utils.js @@ -30,24 +30,15 @@ export function lightenDarkenColor(col,amt) { return (usePound?"#":"") + (g | (b << 8) | (r << 16)).toString(16); } +/** + * Shuffles array in place. ES6 version + * @param {Array} a items An array containing the items. + */ export function shuffle(array) { - // https://stackoverflow.com/a/2450976/6495043 - // Awesomeness: https://bost.ocks.org/mike/shuffle/ + //https://stackoverflow.com/questions/6274339/how-can-i-shuffle-an-array?noredirect=1&lq=1 - var currentIndex = array.length, temporaryValue, randomIndex; - - // While there remain elements to shuffle... - while (0 !== currentIndex) { - - // Pick a remaining element... - randomIndex = Math.floor(Math.random() * currentIndex); - currentIndex -= 1; - - // And swap it with the current element. - temporaryValue = array[currentIndex]; - array[currentIndex] = array[randomIndex]; - array[randomIndex] = temporaryValue; + for (let i = array.length - 1; i > 0; i--) { + let j = Math.floor(Math.random() * (i + 1)); + [array[i], array[j]] = [array[j], array[i]]; } - - return array; -} +} \ No newline at end of file From e44875adfc813265deec264078a3d4b41130f25d Mon Sep 17 00:00:00 2001 From: pratu16x7 Date: Sun, 5 Nov 2017 13:38:56 +0530 Subject: [PATCH 2/2] rebuild sources --- dist/frappe-charts.min.cjs.js | 13 +++++++++++++ dist/frappe-charts.min.esm.js | 13 +++++++++++++ src/scripts/helpers/utils.js | 4 +++- 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/dist/frappe-charts.min.cjs.js b/dist/frappe-charts.min.cjs.js index 5b9de11..b4c93a0 100644 --- a/dist/frappe-charts.min.cjs.js +++ b/dist/frappe-charts.min.cjs.js @@ -550,6 +550,11 @@ function lightenDarkenColor(col, amt) { return (usePound ? "#" : "") + (g | b << 8 | r << 16).toString(16); } +/** + * Shuffles array in place. ES6 version + * @param {Array} a items An array containing the items. + */ + var SvgTip = function () { function SvgTip(_ref) { var _ref$parent = _ref.parent, @@ -3230,6 +3235,14 @@ var Heatmap = function (_BaseChart) { return Heatmap; }(BaseChart); +// if ("development" !== 'production') { +// // Enable LiveReload +// document.write( +// '