|
@@ -27,26 +27,39 @@ Relation.prototype.init = function(){
|
|
|
thisClass.h = $("#entrelation").height();
|
|
|
$("#entrelation-infovis").width(thisClass.w).append(
|
|
|
'<div class="entrelation-controlls hidden-sm hidden-xs">'
|
|
|
- +'<div id="entrelation-pattern" class="entrelation-box" title_pos="left">一般模式</div>'
|
|
|
- +'<div id="entrelation-verbosemode" class="entrelation-box" title_pos="left">详细模式</div>'
|
|
|
- +'<div id="entrelation-fullscreen" class="entrelation-box" title_pos="left">全屏</div>'
|
|
|
+ +'<div id="entrelation-pattern" class="entrelation-box'+(thisClass.modleFlag?' checked':'')+'" title="一般模式"><span class="glyphicon yibanmoshi"></span></div>'
|
|
|
+ +'<div id="entrelation-verbosemode" class="entrelation-box'+(thisClass.modleFlag?'':' checked')+'" title="详细模式"><span class="glyphicon xiangximoshi"></span></div>'
|
|
|
+ +'<div id="entrelation-restore" class="entrelation-box checked" title="退出"><span class="glyphicon suofang"></span></div>'
|
|
|
+ +'<div id="entrelation-fullscreen" class="entrelation-box" title="全屏"><span class="glyphicon quanping"></span></div>'
|
|
|
+'</div>'
|
|
|
);
|
|
|
//一般模式
|
|
|
$("#entrelation-pattern").click(function(){
|
|
|
+ if($(this).hasClass("checked")){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ $("#entrelation-verbosemode").removeClass("checked");
|
|
|
+ $(this).addClass("checked");
|
|
|
thisClass.pattern();
|
|
|
});
|
|
|
//详细模式
|
|
|
$("#entrelation-verbosemode").click(function(){
|
|
|
+ if($(this).hasClass("checked")){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ $("#entrelation-pattern").removeClass("checked");
|
|
|
+ $(this).addClass("checked");
|
|
|
thisClass.verbosemode();
|
|
|
});
|
|
|
//全屏
|
|
|
- $("#entrelation-fullscreen").click(function(){
|
|
|
+ $("#entrelation-restore,#entrelation-fullscreen").click(function(){
|
|
|
+ if($(this).hasClass("checked")){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ $("#entrelation-restore,#entrelation-fullscreen").removeClass("checked");
|
|
|
+ $(this).addClass("checked");
|
|
|
thisClass.initFullScreen();
|
|
|
});
|
|
|
- if($(".entrelation-controlls").length>0){
|
|
|
- $(".entrelation-controlls").css({left:$("#entrelation").width()-$(".entrelation-controlls").width()});
|
|
|
- }
|
|
|
//处理全屏
|
|
|
$(document).on('webkitfullscreenchange mozfullscreenchange msfullscreenchange fullscreenchange', function(){
|
|
|
if (!document.fullscreenElement && !document.mozFullScreenElement && !document.webkitFullscreenElement && !document.msFullscreenElement){
|
|
@@ -84,7 +97,7 @@ Relation.prototype.init = function(){
|
|
|
///////////////////////关系网实例////////////////////////////
|
|
|
var htmls="<div style='position:absolute;top:0px;' class='legend'>";
|
|
|
htmls= htmls+ "<div class='legend-text-bg' style='margin-top: 10px;'><div style='background-color: #ff9800;opacity: 0.8;'></div><span style='margin-left: 20px;color: #ffffff;'>本企业</span></div>";
|
|
|
- htmls= htmls+ "<div class='legend-text-bg' style='margin-top: 10px;'><div style='background-color: #ABE6DB;'></div><span style='margin-left: 12px;'>其他企业</span></div>";
|
|
|
+ htmls= htmls+ "<div class='legend-text-bg' style='margin-top: 10px;'><div style='background-color: #ABE6DB;'></div><span style='margin-left: 12px;color: #056351;'>其他企业</span></div>";
|
|
|
htmls= htmls+ "<div class='legend-text-bg' style='margin-top: 10px;'><div style='background-color: #2196f3;'></div><span style='margin-left: 25px;color: #ffffff;'>个人</span></div>";
|
|
|
htmls= htmls+ "<div class='legend-text-bg' style='margin-top: 10px;margin-bottom: 10px;'><div style='background-color: #afafaf;'></div><span style='margin-left: 5px;color: #ffffff;'>注吊销企业</span></div>";
|
|
|
htmls= htmls+ "<div style='position: relative;'><span style='position: absolute;top: 7.5px;width: 25px;height: 5px;background-color: #e2e2e2;'></span><span style='position: absolute;left: 25px;top: 4px;border-top: 6px solid transparent;border-bottom: 6px solid transparent;border-left: 12px solid #e2e2e2;'></span><span style='margin-left: 45px;'>投资关系(股东→企业)</span></div>";
|
|
@@ -102,7 +115,8 @@ Relation.prototype.pattern = function(){
|
|
|
return;
|
|
|
}
|
|
|
var thisClass = this;
|
|
|
- d3.selectAll("text").each(function (p){
|
|
|
+ d3.selectAll(".textpath").style("display","none");
|
|
|
+ d3.selectAll(".textnode").each(function (p){
|
|
|
if(p.type == "ce" || p.type == "e"){
|
|
|
$(this).text(p.shorttext);
|
|
|
}
|
|
@@ -118,7 +132,8 @@ Relation.prototype.verbosemode = function(){
|
|
|
return;
|
|
|
}
|
|
|
var thisClass = this;
|
|
|
- d3.selectAll("text").each(function (p){
|
|
|
+ d3.selectAll(".textpath").style("display","block");
|
|
|
+ d3.selectAll(".textnode").each(function (p){
|
|
|
if(p.type == "ce" || p.type == "e"){
|
|
|
$(this).text(p.text);
|
|
|
}
|
|
@@ -172,6 +187,7 @@ Relation.prototype.dataProcess = function(){
|
|
|
/*********************************连线处理***********************************/
|
|
|
var minLink=-1,maxLink=-1;
|
|
|
for(var i=0;i<this.data.links.length;i++){
|
|
|
+ this.data.links[i]["nodeId"] = "path-"+(i+1);
|
|
|
var linkObj = this.data.links[i];
|
|
|
if(linkObj.target==this.index && this.data.nodes[linkObj.source].name==this.legcerNo){
|
|
|
//this.data.nodes[linkObj.source].type="cp";
|
|
@@ -393,12 +409,12 @@ Relation.prototype.launchFullScreen = function(element) {
|
|
|
}
|
|
|
Relation.prototype.cancelFullScreen = function(){
|
|
|
this.h = $("#entrelation-infovis").height();
|
|
|
- $("#entrelation-fullscreen").text("全屏").attr("title","进入全屏视图"+((!!window.ActiveXObject || "ActiveXObject" in window)?"":" (F11)"));
|
|
|
+ //$("#entrelation-fullscreen").text("全屏").attr("title","进入全屏视图"+((!!window.ActiveXObject || "ActiveXObject" in window)?"":" (F11)"));
|
|
|
//force.linkDistance(120).charge(-200).size([w,h]).resume();
|
|
|
$("#entrelation-infovis").css({width:this.w,height:this.h});
|
|
|
//设置svg标签的宽度与高度
|
|
|
d3.select("svg").attr("width", this.w).attr("height", this.h);
|
|
|
- $(".entrelation-controlls").css({left:$("#entrelation").width()-$(".entrelation-controlls").width()-30});
|
|
|
+ $(".entrelation-controlls").removeClass("entrelation-controlls-fullscreen");
|
|
|
if(document.exitFullscreen) {
|
|
|
document.exitFullscreen();
|
|
|
} else if (document.msExitFullscreen) {
|
|
@@ -418,7 +434,7 @@ Relation.prototype.initFullScreen = function(){
|
|
|
document.msFullscreenElement;
|
|
|
if(!fullscreenElement || fullscreenElement==null){
|
|
|
this.redrawflag = true;
|
|
|
- $("#entrelation-fullscreen").text("退出").attr("title","退出全屏视图 (F11)");
|
|
|
+ //$("#entrelation-fullscreen").text("退出").attr("title","退出全屏视图 (F11)");
|
|
|
this.launchFullScreen(this.infovisdiv);
|
|
|
var timeout = 100;
|
|
|
if(!!window.ActiveXObject || "ActiveXObject" in window){
|
|
@@ -434,7 +450,7 @@ Relation.prototype.initFullScreen = function(){
|
|
|
//}
|
|
|
$("#entrelation-infovis").css({width:w,height:h});
|
|
|
d3.select("svg").attr("width", w).attr("height", h);
|
|
|
- $(".entrelation-controlls").css({left:w-$(".entrelation-controlls").width() - 70});
|
|
|
+ $(".entrelation-controlls").addClass("entrelation-controlls-fullscreen");
|
|
|
thisClass.force.linkDistance(h).charge(-700).size([w,h]).resume();
|
|
|
}
|
|
|
|
|
@@ -483,14 +499,16 @@ Relation.prototype.removeNode = function(obj){
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
- d3.selectAll("path").each(function (){
|
|
|
+ d3.selectAll("path").each(function (p){
|
|
|
if(name == this.__data__.target.name){
|
|
|
var fromNodeName = this.__data__.source.name;
|
|
|
d3.select(this).remove();
|
|
|
+ $('#text'+p.nodeId).parent().remove();
|
|
|
removeAloneNode(fromNodeName);
|
|
|
}else if(name == this.__data__.source.name){
|
|
|
var toNodeName = this.__data__.target.name;
|
|
|
d3.select(this).remove();
|
|
|
+ $('#text'+p.nodeId).parent().remove();
|
|
|
removeAloneNode(toNodeName);
|
|
|
}
|
|
|
});
|
|
@@ -543,34 +561,6 @@ Relation.prototype.tick = function(){
|
|
|
}
|
|
|
return "translate(" + d.x + "," + d.y + ")scale(" + thisClass.zoomlevel+ ")";
|
|
|
});
|
|
|
- /*this.lineLables.attr("transform",function(d){
|
|
|
- var sx = d.source.x,
|
|
|
- sy = d.source.y,
|
|
|
- x = d.target.x,
|
|
|
- y = d.target.y;
|
|
|
- if(sy > y){
|
|
|
- sy -= 12;
|
|
|
- }else{
|
|
|
- sy += 5;
|
|
|
- }
|
|
|
- var line = new geo.LineSegment(sx, sy, x, y);
|
|
|
- for (var e in d.target.edge) {
|
|
|
- var ix = line.intersect(d.target.edge[e].offset(x, y));
|
|
|
- if (ix.in1 && ix.in2) {
|
|
|
- x = ix.x;
|
|
|
- y = ix.y;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- var dx = x - sx,
|
|
|
- dy = y - sy,
|
|
|
- dr = Math.sqrt(dx * dx + dy * dy);
|
|
|
- var cx = (sx + x) / 2,
|
|
|
- cy = (sy + y) / 2,
|
|
|
- cr = dr - Math.sqrt(Math.pow(dr,2) - Math.pow(dr / 2,2));
|
|
|
- //var c = convert(sx,sy,x,y,0,0,dr,dr,0);
|
|
|
- return "translate("+(cx-cr)+","+(cy-cr)+")";
|
|
|
- });*/
|
|
|
if(thisClass.tickFlag){
|
|
|
thisClass.force.tick();
|
|
|
}
|
|
@@ -587,8 +577,9 @@ Relation.prototype.highlightObject = function(obj,flag){
|
|
|
d3.selectAll(".node").each(function (){
|
|
|
d3.select(this).style("opacity","1");
|
|
|
});
|
|
|
- d3.selectAll("path").each(function (){
|
|
|
+ d3.selectAll("path").each(function (p){
|
|
|
d3.select(this).style("opacity","1");
|
|
|
+ d3.select("#text"+p.nodeId).style("opacity","1");
|
|
|
});
|
|
|
return;
|
|
|
}
|
|
@@ -598,15 +589,17 @@ Relation.prototype.highlightObject = function(obj,flag){
|
|
|
d3.select(this).style("opacity","0.2");
|
|
|
}
|
|
|
});
|
|
|
- d3.selectAll("path").each(function (){
|
|
|
+ d3.selectAll("path").each(function (p){
|
|
|
var targetName = this.__data__.target.name;
|
|
|
var sourceName = this.__data__.source.name;
|
|
|
if(name != targetName && name != sourceName){
|
|
|
d3.select(this).style("opacity","0.2");
|
|
|
+ d3.select("#text"+p.nodeId).style("opacity","0.2");
|
|
|
}else{
|
|
|
d3.selectAll(".node").each(function (){
|
|
|
if(targetName == this.__data__.name || sourceName == this.__data__.name){
|
|
|
d3.select(this).style("opacity","1");
|
|
|
+ d3.select("#text"+p.nodeId).style("opacity","1");
|
|
|
}
|
|
|
});
|
|
|
}
|
|
@@ -649,16 +642,21 @@ Relation.prototype.makeRelation = function(){
|
|
|
var zoom = d3.behavior.zoom().scaleExtent([0.4, 10]).on("zoom", function(){
|
|
|
thisClass.zoomed();
|
|
|
});
|
|
|
+
|
|
|
this.svg = d3.select("#entrelation-infovis").append("svg:svg")
|
|
|
.attr("width", this.w)
|
|
|
.attr("height", this.h)
|
|
|
.call(zoom)
|
|
|
.append("g");
|
|
|
- var gs = this.svg.append("svg:g")
|
|
|
+
|
|
|
+ this.lines = this.svg.append("svg:g")
|
|
|
.selectAll("path")
|
|
|
.data(this.force.links())
|
|
|
- .enter();
|
|
|
- this.lines = gs.append("path")
|
|
|
+ .enter()
|
|
|
+ .append("path")
|
|
|
+ .attr("id",function(p){
|
|
|
+ return p.nodeId;
|
|
|
+ })
|
|
|
.style("fill", function(p){
|
|
|
return (p.type=="cp" || p.isLegal)?"#cd93d7":"#e2e2e2";
|
|
|
})
|
|
@@ -668,18 +666,37 @@ Relation.prototype.makeRelation = function(){
|
|
|
.attr("stroke-width",function (e,i){
|
|
|
return e.linkVal;
|
|
|
});
|
|
|
- /*this.lineLables = gs.append("g").each(function(d){
|
|
|
- var invacconam = new Number(d.invacconam);
|
|
|
- if(invacconam > 0){
|
|
|
- var lenInvacconam = (invacconam + "").length;
|
|
|
- if(lenInvacconam > 4 && (invacconam + "").indexOf(".") > -1 && (lenInvacconam - (invacconam + "").indexOf(".")) > 4){
|
|
|
- invacconam = (new Number(invacconam)).toFixed(4);
|
|
|
+
|
|
|
+ this.svg.append("svg:g")
|
|
|
+ .selectAll("textPath")
|
|
|
+ .data(this.force.links())
|
|
|
+ .enter()
|
|
|
+ .append("text")
|
|
|
+ .attr("x", "0")
|
|
|
+ .attr("y", "0")
|
|
|
+ .append("textPath")
|
|
|
+ .attr("class", "textpath")
|
|
|
+ .attr("id", function(d) {
|
|
|
+ return 'text'+d.nodeId;
|
|
|
+ })
|
|
|
+ .attr("xlink:href", function(d) {
|
|
|
+ return '#'+d.nodeId;
|
|
|
+ })
|
|
|
+ .text(function(d) {
|
|
|
+ var invacconam = new Number(d.invacconam);
|
|
|
+ if(invacconam > 0){
|
|
|
+ var lenInvacconam = (invacconam + "").length;
|
|
|
+ if(lenInvacconam > 4 && (invacconam + "").indexOf(".") > -1 && (lenInvacconam - (invacconam + "").indexOf(".")) > 4){
|
|
|
+ invacconam = (new Number(invacconam)).toFixed(4);
|
|
|
+ }
|
|
|
+ return invacconam+"万元";
|
|
|
+ }else{
|
|
|
+ return "";
|
|
|
}
|
|
|
- d3.select(this).append("text").text(invacconam+"万元");
|
|
|
- }else{
|
|
|
- d3.select(this).remove();
|
|
|
- }
|
|
|
- });*/
|
|
|
+ })
|
|
|
+ .style("fill", "#4e5051")
|
|
|
+ .attr("startOffset", "20%")
|
|
|
+ .style("display", this.modleFlag?"none":"block");
|
|
|
|
|
|
this.lines.each(function (d,i){
|
|
|
var invacconam = new Number(d.invacconam);
|
|
@@ -732,8 +749,9 @@ Relation.prototype.makeRelation = function(){
|
|
|
});
|
|
|
this.makeTitle();
|
|
|
this.nodes.append('text')
|
|
|
+ .attr("class","textnode")
|
|
|
.text(function(d){
|
|
|
- if(thisClass.modleFlag){
|
|
|
+ if(d.type != "p" && thisClass.modleFlag){
|
|
|
return d.shorttext;
|
|
|
}else{
|
|
|
return d.text;
|
|
@@ -757,7 +775,7 @@ Relation.prototype.makeRelation = function(){
|
|
|
if(p.type == "e" && (p.opstate == "11" || p.opstate == "07")){
|
|
|
return "#ffffff";
|
|
|
}
|
|
|
- return p.type=="p"?"#ffffff":p.type=="ce"?"#ffffff":"auto";
|
|
|
+ return p.type=="p"?"#ffffff":p.type=="ce"?"#ffffff":"#056351";
|
|
|
})
|
|
|
.on("click",function (d,i){
|
|
|
if(!dragstatus && d.type == "e"){
|
|
@@ -859,112 +877,4 @@ Relation.prototype.makeTextBg = function(){
|
|
|
bottom : new geo.LineSegment(bounds.x1, bounds.y2, bounds.x2, bounds.y2)
|
|
|
};
|
|
|
});
|
|
|
-}
|
|
|
-// svg : [A | a] (rx ry x-axis-rotation large-arc-flag sweep-flag x y)+
|
|
|
-
|
|
|
-/* x1 y1 x2 y2 fA fS rx ry φ */
|
|
|
-function radian( ux, uy, vx, vy ) {
|
|
|
- var dot = ux * vx + uy * vy;
|
|
|
- var mod = Math.sqrt( ( ux * ux + uy * uy ) * ( vx * vx + vy * vy ) );
|
|
|
- var rad = Math.acos( dot / mod );
|
|
|
- if( ux * vy - uy * vx < 0.0 ) rad = -rad;
|
|
|
- return rad;
|
|
|
-}
|
|
|
-//https://www.w3.org/TR/SVG11/implnote.html#ArcImplementationNotes
|
|
|
-//conversion_from_endpoint_to_center_parameterization
|
|
|
-//sample : convert(200,200,300,200,1,1,50,50,0,{})
|
|
|
-function convert(x1, y1, x2, y2, fA, fS, rx, ry, phi) {
|
|
|
- var cx,cy,theta1,delta_theta;
|
|
|
-
|
|
|
- if( rx == 0.0 || ry == 0.0 ) return -1; // invalid arguments
|
|
|
-
|
|
|
- var s_phi = Math.sin( phi );
|
|
|
- var c_phi = Math.cos( phi );
|
|
|
- var hd_x = ( x1 - x2 ) / 2.0; // half diff of x
|
|
|
- var hd_y = ( y1 - y2 ) / 2.0; // half diff of y
|
|
|
- var hs_x = ( x1 + x2 ) / 2.0; // half sum of x
|
|
|
- var hs_y = ( y1 + y2 ) / 2.0; // half sum of y
|
|
|
-
|
|
|
- // F6.5.1
|
|
|
- var x1_ = c_phi * hd_x + s_phi * hd_y;
|
|
|
- var y1_ = c_phi * hd_y - s_phi * hd_x;
|
|
|
-
|
|
|
- var rxry = rx * ry;
|
|
|
- var rxy1_ = rx * y1_;
|
|
|
- var ryx1_ = ry * x1_;
|
|
|
- var sum_of_sq = rxy1_ * rxy1_ + ryx1_ * ryx1_; // sum of square
|
|
|
- var coe = Math.sqrt( ( rxry * rxry - sum_of_sq ) / sum_of_sq );
|
|
|
- if( fA == fS ) coe = -coe;
|
|
|
-
|
|
|
- // F6.5.2
|
|
|
- var cx_ = coe * rxy1_ / ry;
|
|
|
- var cy_ = -coe * ryx1_ / rx;
|
|
|
-
|
|
|
- // F6.5.3
|
|
|
- cx = c_phi * cx_ - s_phi * cy_ + hs_x;
|
|
|
- cy = s_phi * cx_ + c_phi * cy_ + hs_y;
|
|
|
-
|
|
|
- var xcr1 = ( x1_ - cx_ ) / rx;
|
|
|
- var xcr2 = ( x1_ + cx_ ) / rx;
|
|
|
- var ycr1 = ( y1_ - cy_ ) / ry;
|
|
|
- var ycr2 = ( y1_ + cy_ ) / ry;
|
|
|
-
|
|
|
- // F6.5.5
|
|
|
- theta1 = radian( 1.0, 0.0, xcr1, ycr1 );
|
|
|
-
|
|
|
- // F6.5.6
|
|
|
- delta_theta = radian( xcr1, ycr1, -xcr2, -ycr2 );
|
|
|
- var PIx2 = Math.PI * 2.0;
|
|
|
- while( delta_theta > PIx2 ) delta_theta -= PIx2;
|
|
|
- while( delta_theta < 0.0 ) delta_theta += PIx2;
|
|
|
- if( fS == false ) delta_theta -= PIx2;
|
|
|
-
|
|
|
- var outputObj = { /* cx, cy, theta1, delta_theta */
|
|
|
- cx : cx,
|
|
|
- cy : cy,
|
|
|
- theta1 : theta1,
|
|
|
- delta_theta : delta_theta
|
|
|
- }
|
|
|
- console.dir(outputObj);
|
|
|
-
|
|
|
- return outputObj;
|
|
|
-}
|
|
|
-function convert_tmp(x1, y1, x2, y2, fA, fS, rx, ry, phi) {
|
|
|
- var cx,cy,theta1,delta_theta;
|
|
|
-
|
|
|
- if( rx == 0.0 || ry == 0.0 ) return -1; // invalid arguments
|
|
|
-
|
|
|
- var s_phi = Math.sin( phi );
|
|
|
- var c_phi = Math.cos( phi );
|
|
|
- var hd_x = ( x1 - x2 ) / 2.0; // half diff of x
|
|
|
- var hd_y = ( y1 - y2 ) / 2.0; // half diff of y
|
|
|
- var hs_x = ( x1 + x2 ) / 2.0; // half sum of x
|
|
|
- var hs_y = ( y1 + y2 ) / 2.0; // half sum of y
|
|
|
-
|
|
|
- // F6.5.1
|
|
|
- var x1_ = c_phi * hd_x + s_phi * hd_y;
|
|
|
- var y1_ = c_phi * hd_y - s_phi * hd_x;
|
|
|
-
|
|
|
- var rxry = rx * ry;
|
|
|
- var rxy1_ = rx * y1_;
|
|
|
- var ryx1_ = ry * x1_;
|
|
|
- var sum_of_sq = rxy1_ * rxy1_ + ryx1_ * ryx1_; // sum of square
|
|
|
- var coe = Math.sqrt( ( rxry * rxry - sum_of_sq ) / sum_of_sq );
|
|
|
- if( fA == fS ) coe = -coe;
|
|
|
-
|
|
|
- // F6.5.2
|
|
|
- var cx_ = coe * rxy1_ / ry;
|
|
|
- var cy_ = -coe * ryx1_ / rx;
|
|
|
-
|
|
|
- // F6.5.3
|
|
|
- cx = c_phi * cx_ - s_phi * cy_ + hs_x;
|
|
|
- cy = s_phi * cx_ + c_phi * cy_ + hs_y;
|
|
|
-
|
|
|
- var outputObj = { /* cx, cy */
|
|
|
- cx : rxry,
|
|
|
- cy : rxy1_
|
|
|
- }
|
|
|
- console.dir(outputObj);
|
|
|
-
|
|
|
- return outputObj;
|
|
|
}
|