From 9e3e1cad9a64ee346cee0c7cf9c239c0d5ca1088 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa=20Aubert?= Date: Wed, 6 Sep 2017 15:47:21 +0200 Subject: [PATCH] Move getWidth function to a class method --- lib/cartodb/models/dataview/histogram.js | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/lib/cartodb/models/dataview/histogram.js b/lib/cartodb/models/dataview/histogram.js index c2df2c5f..3e9868d9 100644 --- a/lib/cartodb/models/dataview/histogram.js +++ b/lib/cartodb/models/dataview/histogram.js @@ -584,7 +584,7 @@ module.exports = class Histogram extends BaseWidget { var buckets = []; var binsCount = this.getBinsCount(override); - var width = getWidth(override); + var width = this.getWidth(override); var binsStart = this.getBinStart(override); var nulls = 0; var infinities = 0; @@ -697,6 +697,17 @@ module.exports = class Histogram extends BaseWidget { getBinsCount (override) { return override.bins || 0; } + + getWidth (override) { + var width = 0; + var binsCount = override.bins; + + if (binsCount && Number.isFinite(override.start) && Number.isFinite(override.end)) { + width = (override.end - override.start) / binsCount; + } + + return width; + } }; var DATE_AGGREGATIONS = { @@ -710,16 +721,6 @@ var DATE_AGGREGATIONS = { 'year': true }; -function getWidth(override) { - var width = 0; - var binsCount = override.bins; - - if (binsCount && Number.isFinite(override.start) && Number.isFinite(override.end)) { - width = (override.end - override.start) / binsCount; - } - - return width; -} function parseOffset(offset, aggregation) { if (!offset) {