From 49d89cc0ea4979249967843ae9171990c2d6d809 Mon Sep 17 00:00:00 2001 From: David Miller Date: Tue, 6 Aug 2013 18:26:12 +0100 Subject: [PATCH] Only create variables if we need them. --- src/view.flot.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/view.flot.js b/src/view.flot.js index 4e111fe5..1b50f063 100644 --- a/src/view.flot.js +++ b/src/view.flot.js @@ -313,8 +313,6 @@ my.Flot = Backbone.View.extend({ var points = []; var fieldLabel = self.model.fields.get(field).get('label'); - var raw = _.map(self.model.records.models, function(doc, index){ return doc.getFieldValueUnrendered(xfield) }); - if (isDateTime){ var cast = function(x){ var _date = moment(String(x)); @@ -323,10 +321,17 @@ my.Flot = Backbone.View.extend({ } return x } - } else if (_.all(raw, function(x){ return !isNaN(parseFloat(x)) })){ - var cast = function(x){ return parseFloat(x) } } else { - self.xvaluesAreIndex = true + var raw = _.map(self.model.records.models, + function(doc, index){ + return doc.getFieldValueUnrendered(xfield) + }); + + if (_.all(raw, function(x){ return !isNaN(parseFloat(x)) })){ + var cast = function(x){ return parseFloat(x) } + } else { + self.xvaluesAreIndex = true + } } _.each(self.model.records.models, function(doc, index) {