Skip to content

Instantly share code, notes, and snippets.

@purplefeel
Last active February 14, 2019 05:17
Show Gist options
  • Save purplefeel/4df14f49a43431a52c3f45bd2ac8594b to your computer and use it in GitHub Desktop.
Save purplefeel/4df14f49a43431a52c3f45bd2ac8594b to your computer and use it in GitHub Desktop.
// Gererate Random Integer Array for demo data
getRandomSeries = (min, max) => {
const count = (this.item.range == 'MTD') ? this.dayArray.length - 1 : this.monthArray.length - 1;
let arr = [];
for (let i = 0; i < count; i++) {
arr.push(Math.floor(Math.random() * (max - min)) + min);
}
return arr;
}
getRandomValue = (min, max) => {
return Math.floor(Math.random() * (max - min)) + min;
}
// To convert table column name to camel case
camelize(str: String) {
return str.replace(/(?:^\w|[A-Z]|\b\w)/g, function(letter, index) {
return index == 0 ? letter.toLowerCase() : letter.toUpperCase();
}).replace(/\s+/g, '');
}
// Format number with thoudand separater
numberWithCommas = value => {
return value.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment