浏览代码

Merge pull request #22 from AhmadShahid/master

add ES6 implementation of a shuffle function
tags/1.2.0
Prateeksha Singh 7 年前
committed by GitHub
父节点
当前提交
87ea03af19
找不到此签名对应的密钥 GPG 密钥 ID: 4AEE18F83AFDEB23
共有 3 个文件被更改,包括 36 次插入17 次删除
  1. +13
    -0
      dist/frappe-charts.min.cjs.js
  2. +13
    -0
      dist/frappe-charts.min.esm.js
  3. +10
    -17
      src/scripts/helpers/utils.js

+ 13
- 0
dist/frappe-charts.min.cjs.js 查看文件

@@ -550,6 +550,11 @@ function lightenDarkenColor(col, amt) {
return (usePound ? "#" : "") + (g | b << 8 | r << 16).toString(16); 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 () { var SvgTip = function () {
function SvgTip(_ref) { function SvgTip(_ref) {
var _ref$parent = _ref.parent, var _ref$parent = _ref.parent,
@@ -3230,6 +3235,14 @@ var Heatmap = function (_BaseChart) {
return Heatmap; return Heatmap;
}(BaseChart); }(BaseChart);


// if ("development" !== 'production') {
// // Enable LiveReload
// document.write(
// '<script src="http://' + (location.host || 'localhost').split(':')[0] +
// ':35729/livereload.js?snipver=1"></' + 'script>'
// );
// }

var chartTypes = { var chartTypes = {
line: LineChart, line: LineChart,
bar: BarChart, bar: BarChart,


+ 13
- 0
dist/frappe-charts.min.esm.js 查看文件

@@ -548,6 +548,11 @@ function lightenDarkenColor(col, amt) {
return (usePound ? "#" : "") + (g | b << 8 | r << 16).toString(16); 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 () { var SvgTip = function () {
function SvgTip(_ref) { function SvgTip(_ref) {
var _ref$parent = _ref.parent, var _ref$parent = _ref.parent,
@@ -3228,6 +3233,14 @@ var Heatmap = function (_BaseChart) {
return Heatmap; return Heatmap;
}(BaseChart); }(BaseChart);


// if ("development" !== 'production') {
// // Enable LiveReload
// document.write(
// '<script src="http://' + (location.host || 'localhost').split(':')[0] +
// ':35729/livereload.js?snipver=1"></' + 'script>'
// );
// }

var chartTypes = { var chartTypes = {
line: LineChart, line: LineChart,
bar: BarChart, bar: BarChart,


+ 10
- 17
src/scripts/helpers/utils.js 查看文件

@@ -30,24 +30,17 @@ export function lightenDarkenColor(col,amt) {
return (usePound?"#":"") + (g | (b << 8) | (r << 16)).toString(16); 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) { export function shuffle(array) {
// https://stackoverflow.com/a/2450976/6495043
// Awesomeness: https://bost.ocks.org/mike/shuffle/ // Awesomeness: https://bost.ocks.org/mike/shuffle/
// https://stackoverflow.com/a/2450976/6495043
// 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;
}
}

正在加载...
取消
保存