This commit is contained in:
Jackson Tian 2012-11-04 22:47:37 +08:00
parent 3e45317578
commit 51187b8002
2 changed files with 16 additions and 21 deletions

View File

@ -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 = '<b>' + that.keyDimen + ':{key}</b><br/><b>' +
that.xDimen + ':{xDimen}</b><br/><b>' +
that.yDimen + ':{yDimen}</b><br/><b>' +
@ -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;
};
/**

View File

@ -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],