Commit 8ffbea2f authored by maxchaza's avatar maxchaza

Allows to pass function for attrEditor on selection

parent 6e14de29
......@@ -4,24 +4,33 @@
*/
d3.selection.prototype.attrEditor = function(attr, val) {
var selection = this;
if(!val)
return this.attr(attr);
return selection.attr(attr);
else
{
this.attr(attr, val);
if(attr === "height" || attr === "width"){
this.each(function (n) {
if(attr === "height")
n.setSvgHeight(val);
if(attr === "width")
n.setSvgWidth(val);
if(typeof val === 'function')
{
selection.each(function (n) {
d3.select(this).attrEditor(attr, val(n));
});
this.attr("transform", "translate(-"+(parseFloat(this.attr("width"))/2)+",-"+(parseFloat(this.attr("height"))/2)+") scale(1)");
}
else
{
selection.attr(attr, val);
if(attr === "height" || attr === "width"){
selection.each(function (n) {
if(attr === "height")
n.setSvgHeight(val);
if(attr === "width")
n.setSvgWidth(val);
});
selection.attr("transform", "translate(-"+(parseFloat(this.attr("width"))/2)+",-"+(parseFloat(this.attr("height"))/2)+") scale(1)");
}
}
}
};
......
......@@ -110,6 +110,7 @@ metExploreD3.GraphLink = {
var source, target, path;
function pathForReversibleReactions(source, target) {
var d = Math.sqrt(Math.pow(target.x - source.x, 2) + Math.pow(target.y - source.y, 2));
var dX = (target.x - source.x);
var dY = (target.y - source.y);
......@@ -120,8 +121,8 @@ metExploreD3.GraphLink = {
var largeurNoeudT = (rTW < rTH) ? rT = rTW : rt = rTH;
}
else {
var rTW = (Math.abs(d) * target.getSvgWidth() / 2) / Math.abs(dX);
var rTH = (Math.abs(d) * target.getSvgHeight() / 2) / Math.abs(dY);
var rTW = (Math.abs(d) * source.getSvgWidth() / 2) / Math.abs(dX);
var rTH = (Math.abs(d) * source.getSvgHeight() / 2) / Math.abs(dY);
var largeurNoeudT = (rTW < rTH) ? rT = rTW : rt = rTH;
}
var heightArrow = 5;
......@@ -154,6 +155,7 @@ metExploreD3.GraphLink = {
function path(source, target) {
var d = Math.sqrt(Math.pow(target.x - source.x, 2) + Math.pow(target.y - source.y, 2));
var dX = (target.x - source.x);
var dY = (target.y - source.y);
......@@ -163,8 +165,8 @@ metExploreD3.GraphLink = {
var largeurNoeudT = (rTW < rTH) ? rT = rTW : rt = rTH;
}
else {
var rTW = (Math.abs(d) * target.getSvgWidth() / 2) / Math.abs(dX);
var rTH = (Math.abs(d) * target.getSvgHeight() / 2) / Math.abs(dY);
var rTW = (Math.abs(d) * source.getSvgWidth() / 2) / Math.abs(dX);
var rTH = (Math.abs(d) * source.getSvgHeight() / 2) / Math.abs(dY);
var largeurNoeudT = (rTW < rTH) ? rT = rTW : rt = rTH;
}
......
......@@ -727,11 +727,11 @@ metExploreD3.GraphStyleEdition = {
var targetSelection = selection.selectAll(target);
targetSelection[attrType](attrName, function(d){
function test(d){
var map = d.getMappingDataByNameAndCond(mappingName, conditionName);
return linearScale(map.getMapValue());
});
}
targetSelection[attrType](attrName, test);
targetSelection.classed("mapped"+attrType+attrName+biologicalType, true);
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment