From b53ab615eaa4e71cd71112b70176cb1cc78608c6 Mon Sep 17 00:00:00 2001 From: michnovka Date: Wed, 17 Jan 2018 03:15:56 +0100 Subject: [PATCH] added default precision modifier plot now accepts precision for default modifier --- asciichart.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/asciichart.js b/asciichart.js index 8038cf8..3798f9e 100644 --- a/asciichart.js +++ b/asciichart.js @@ -16,6 +16,7 @@ cfg = (typeof cfg !== 'undefined') ? cfg : {} let offset = (typeof cfg.offset !== 'undefined') ? cfg.offset : 3 let padding = (typeof cfg.padding !== 'undefined') ? cfg.padding : ' ' + let precision = (typeof cfg.precision !== 'undefined') ? cfg.precision : 2 let height = (typeof cfg.height !== 'undefined') ? cfg.height : range let ratio = height / range let min2 = Math.round (min * ratio) @@ -23,7 +24,7 @@ let rows = Math.abs (max2 - min2) let width = series.length + offset let format = (typeof cfg.format !== 'undefined') ? cfg.format : function (x) { - return (padding + x.toFixed (2)).slice (-padding.length) + return (padding + x.toFixed (precision)).slice (-padding.length) } let result = new Array (rows + 1) // empty space @@ -62,4 +63,4 @@ return result.map (function (x) { return x.join ('') }).join ('\n') } -}) (typeof exports === 'undefined' ? /* istanbul ignore next */ this['asciichart'] = {} : exports); \ No newline at end of file +}) (typeof exports === 'undefined' ? /* istanbul ignore next */ this['asciichart'] = {} : exports);