Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: jlebensold/swivel
base: e885b1899c
...
head fork: jlebensold/swivel
compare: be91c80767
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 1 file changed
  • 0 commit comments
  • 1 contributor
Showing with 17 additions and 19 deletions.
  1. +17 −19 public/js/GridView.js
View
36 public/js/GridView.js
@@ -53,22 +53,14 @@ window.GridView = Backbone.View.extend({
addTile: function() {
this.bucketize(this.collection.bucketing);
this.createVis();
- this.animate();
},
sortTiles: function() {
this.loadData();
- this.animate();
},
removeTile: function() {
this.loadData();
-
- this.vis.selectAll(".tiles").data(this.data).exit()
- .transition().duration(500)
- .attr("transform",function(d) {return "translate("+((0.5 - Math.random())*10000)+","+((0.5 - Math.random())*10000)+")"})
- .remove();
- this.animate();
},
resizeCurrentTiles: function() {
@@ -201,15 +193,23 @@ window.GridView = Backbone.View.extend({
animation.attr("transform",function(d) {return "translate("+(d.x+d.h)+","+(d.y+d.w)+")scale(-1,-1)";});
- //TODO: figure out why tileSize needs to be globally referenced and why data() doesn't work
- var self = this;
- animation.selectAll(".tiles rect")
- .attr("height", function(d) { return self.tileSize; } )
- .attr("width", function(d) { return self.tileSize; } );
+ this.vis.selectAll("rect")
+ .data(this.data, function(d) {return d.cid})
+ .attr("height", function(d) { console.log(d.cid, d.h);return d.h; } )
+ .attr("width", function(d) { return d.w; } );
+
+ this.vis.selectAll("image")
+ .data(this.data, function(d) {return d.cid})
+ .attr("height", function(d) { return d.h; } )
+ .attr("width", function(d) { return d.w; } );
- animation.selectAll(".tiles image")
- .attr("height", function(d) { return self.tileSize; } )
- .attr("width", function(d) { return self.tileSize; } );
+ this.vis.selectAll(".tiles").data(this.data, function(d) { return d.cid;}).exit()
+ .transition().duration(this.animationDuration)
+ .attr("transform",function(d) {
+ var x = (0.5 - Math.random())*10000;
+ var y = (0.5 - Math.random())*10000;
+ return "translate("+x+","+y+")"})
+ .remove();
},
createVis: function(){
@@ -218,7 +218,6 @@ window.GridView = Backbone.View.extend({
.data(this.data, function(d) {return d.cid})
.enter()
.append("g")
- .attr("id",function(d) { return d.cid })
.attr("class","tiles")
.attr("transform",function(d) {
var x = (0.5 - Math.random())*10000;
@@ -228,6 +227,7 @@ window.GridView = Backbone.View.extend({
rects.append("rect")
.attr("class", "rect")
+ .attr("id",function(d) { return d.cid })
.attr("height", function(d) { return d.h; } )
.attr("width", function(d) { return d.w; } )
.attr("fill", function(d) { return 'black'; });
@@ -235,11 +235,9 @@ window.GridView = Backbone.View.extend({
if (this.tileTemplate) this.tileTemplate(rects);
-// this.vis.selectAll(".tiles").data(this.data).exit().remove();
var self = this;
this.vis.selectAll("rect").on("click",function(d) {
- self.tileClicked(d.model);
});
},

No commit comments for this range

Something went wrong with that request. Please try again.