I'm trying to create arbitrary groups of columns and rows using these attributes in the objects:
var svg = d3.select("#right-section").append("svg").attr("width",600).attr("height",600);
var flatInputMatrix = [1,1,1,0,0,3,3,3,0,0,4,4,4,0,0,5,5,5,0,0,0,2,0,4,4,0,0,0,5,5,0,1,0,2,2];
var m = 5;
var r = 3;
var counter = -1;
var data = flatInputMatrix.map(function(d, i) {
i % m === 0 ? counter++ : null;
return {
column: i % m,
row: counter,
value: d
};
});
var columnsGroups = svg.append("g")
var columns = columnsGroups.selectAll("columns").data(data.column= this.column).enter()
var numbers = svg.selectAll("numbers").data(data).enter().append("text")
.attr("x",function(d,i) { return (i % m)*50 + 10 + r; })
.attr("y",function(d,i) { return Math.floor(i / m) *50+50; })
.style("opacity", 0.5)
.text(function(d) { return d.value; })
.on("mouseover", function(d.columns){d3.select(this).style("opacity", 1) })
The idea is to have a column (later a group of columns) have the opacity = 1 when it is hovered over by the cursor.