diff --git a/lib/charts/bubble.js b/lib/charts/bubble.js index 7a97ab4..0bc0720 100644 --- a/lib/charts/bubble.js +++ b/lib/charts/bubble.js @@ -68,7 +68,7 @@ }); /** - * create a backCanvas for the visualization + * Creates a backCanvas for the visualization */ Bubble.prototype.createCanvas = function () { var conf = this.defaults; @@ -90,7 +90,7 @@ }; /** - * choose bubble graph setted visualization dimens orderly + * Chooses bubble graph setted visualization dimens orderly */ Bubble.prototype.chooseDimensions = function (dimen) { var conf = this.defaults; @@ -130,10 +130,10 @@ conf.dimensions = source[0]; this.source = []; - for(var i = 1, l = source.length; i < l; i++){ + for (var i = 1, l = source.length; i < l; i++){ var dot = {}, dimen = conf.allDimensions; - for(var j=0, ll=dimen.length; j < ll; j++){ + for (var j=0, ll=dimen.length; j < ll; j++){ dot[dimen[j]] = source[i][j]; } this.source.push(dot); @@ -141,14 +141,11 @@ // judge dimesions type auto conf.dimensionType = {}; - function isNumber(n) { - return !isNaN(parseFloat(n)) && isFinite(n); - } - for(var i = 0, l = conf.allDimensions.length; i < l; i++){ + for (var i = 0, l = conf.allDimensions.length; i < l; i++){ var type = "quantitative"; - for(var j = 1, ll = source.length; j < ll; j++){ + for (var j = 1, ll = source.length; j < ll; j++){ var d = source[j][i]; - if(d && (! isNumber(d))){ + if(d && (!DataV.isNumeric(d))){ type = "ordinal"; break; } @@ -157,12 +154,12 @@ } // set default dimensionDomain - for(var i = 0, l = conf.allDimensions.length; i < l; i++){ + for (var i = 0, l = conf.allDimensions.length; i < l; i++){ var dimen = conf.allDimensions[i]; - if(conf.dimensionType[dimen] === "quantitative"){ + if (conf.dimensionType[dimen] === "quantitative") { conf.dimensionDomain[dimen] = d3.extent(this.source, - function(p){return Math.abs(p[dimen])}); - }else{ + function (p) {return Math.abs(p[dimen]);}); + } else { conf.dimensionDomain[dimen] = this.source.map(function(p){return p[dimen]}); } @@ -483,6 +480,7 @@ } var floatTag = this.floatTag; + var that = this; var tip = '' + that.keyDimen + ':{key}
' + that.xDimen + ':{xDimen}
' + that.yDimen + ':{yDimen}
' + @@ -762,7 +760,6 @@ value += 0.25; } else { clearInterval(that.interval); - that.interval = 0; } }, 250); }; @@ -791,7 +788,6 @@ */ Bubble.prototype.clearAnimation = function () { clearInterval(this.interval); - this.interval = 0; this.backCanvas.clear(); this.foreCanvas.clear(); }; @@ -801,7 +797,6 @@ */ Bubble.prototype.pause = function () { clearInterval(this.interval); - this.interval = 0; }; /** diff --git a/test/lib.chord.js b/test/lib.chord.js index e2f1a34..c68b4a2 100644 --- a/test/lib.chord.js +++ b/test/lib.chord.js @@ -7,19 +7,19 @@ test("prototype.createCanvas", function () { equal(fdnet.defaults.innerRadius, 328, "innerRadius should be 328 by default"); fdnet.createCanvas(); - + equal(typeof fdnet.canvas, "object", "canvas should be an object"); }); test("prototype.setSource", function () { - var source=[ + var source = [ ["A", "B", "C", "D"], [11975, 5871, 8916, 2868], [1951, 10048, 2060, 6171], [8010, 16145, 8090, 8045], [1013, 990, 940, 6907] ]; - + fdnet.setSource(source); equal(fdnet.matrix.length, 4, "There should be 4 groups."); @@ -29,7 +29,7 @@ test("prototype.setSource", function () { }); test("prototype.render", function () { - var source=[ + var source = [ ["A", "B", "C", "D"], [11975, 5871, 8916, 2868], [1951, 10048, 2060, 6171],