Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // figures out a good scope to use based on the data
- // this is pretty basic, but does an ok job
- var data = [
- { "label": "first", "value": 30 },
- { "label": "second", "value": 86 },
- { "label": "third", "value": 168 },
- { "label": "fourth", "value": 281 },
- { "label": "fifth", "value": 303 },
- { "label": "sixth", "value": 365 },
- ];
- var scope = 0;
- data.forEach(function(element) {
- if (element.value > scope) {
- scope = element.value;
- }
- });
- // factor = "1".padEnd((scope.toString().length), "0");
- // var temp = scope / factor;
- // var temp2 = Math.ceil(temp);
- // var temp3 = temp2 * "1".padEnd((scope.toString().length), "0");
- // console.log({ scope, factor, temp, temp2, temp3 });
- // simplified version of above:
- scope = (Math.ceil(scope / ("1".padEnd((scope.toString().length), "0")))) * "1".padEnd((scope.toString().length), "0");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement