|
@@ -4,6 +4,7 @@ function Relation(legcerNo,regNo,regCapCurName,data){
|
|
|
this.regCapCurName = regCapCurName;
|
|
|
this.data = data;
|
|
|
this.modleFlag = data.nodes.length>15;
|
|
|
+ this.defaultIsPattern = this.modleFlag;
|
|
|
this.zoomlevel = 1;
|
|
|
this.w = 0;
|
|
|
this.h = 0;
|
|
@@ -25,8 +26,10 @@ Relation.prototype.init = function(){
|
|
|
var thisClass = this;
|
|
|
thisClass.w = $("#entrelation").width();
|
|
|
thisClass.h = $("#entrelation").height();
|
|
|
+ thisClass.centerNodeX = thisClass.w / 2;
|
|
|
+ thisClass.centerNodeY = thisClass.h / 2 + 5;
|
|
|
$("#entrelation-infovis").width(thisClass.w).append(
|
|
|
- '<div class="entrelation-controlls hidden-sm">'
|
|
|
+ '<div class="entrelation-controlls">'
|
|
|
+'<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>'
|
|
@@ -35,20 +38,14 @@ Relation.prototype.init = function(){
|
|
|
);
|
|
|
//一般模式
|
|
|
$("#entrelation-pattern").click(function(){
|
|
|
- if($(this).hasClass("checked")){
|
|
|
- return;
|
|
|
- }
|
|
|
- $("#entrelation-verbosemode").removeClass("checked");
|
|
|
- $(this).addClass("checked");
|
|
|
+ $(this).hide();
|
|
|
+ $("#entrelation-verbosemode").show();
|
|
|
thisClass.pattern();
|
|
|
});
|
|
|
//详细模式
|
|
|
$("#entrelation-verbosemode").click(function(){
|
|
|
- if($(this).hasClass("checked")){
|
|
|
- return;
|
|
|
- }
|
|
|
- $("#entrelation-pattern").removeClass("checked");
|
|
|
- $(this).addClass("checked");
|
|
|
+ $(this).hide();
|
|
|
+ $("#entrelation-pattern").show();
|
|
|
thisClass.verbosemode();
|
|
|
});
|
|
|
//全屏
|
|
@@ -83,13 +80,13 @@ Relation.prototype.init = function(){
|
|
|
thisClass.cancelFullScreen();
|
|
|
}
|
|
|
};
|
|
|
- $(window).resize(function(){
|
|
|
+ /*$(window).resize(function(){
|
|
|
if(!thisClass.redrawflag){
|
|
|
//1秒后重绘
|
|
|
thisClass.redrawflag=true;
|
|
|
setTimeout(thisClass.redraw,1000);
|
|
|
}
|
|
|
- });
|
|
|
+ });*/
|
|
|
if(document.getElementById("entrelation-infovis")){
|
|
|
document.getElementById("entrelation-infovis").oncontextmenu=function(){return false;};
|
|
|
}
|
|
@@ -141,8 +138,14 @@ Relation.prototype.verbosemode = function(){
|
|
|
this.modleFlag = false;
|
|
|
this.makeTextBg();
|
|
|
this.makeTitle();
|
|
|
- this.tick();
|
|
|
- this.force.tick();
|
|
|
+ if(this.defaultIsPattern){
|
|
|
+ this.tickFlag = true;
|
|
|
+ this.force.linkDistance(Math.floor(Math.random()*60)+150).start();
|
|
|
+ }else{
|
|
|
+ this.tick();
|
|
|
+ this.force.tick();
|
|
|
+ }
|
|
|
+ this.defaultIsPattern = false;
|
|
|
}
|
|
|
Relation.prototype.dataProcess = function(){
|
|
|
var reg = new RegExp(/(有限公司|有限责任公司|股份有限公司|总公司|分公司|公司|事务所|合伙企业)$|\(.*\)|\(.*\)/g);
|
|
@@ -408,13 +411,14 @@ 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)"));
|
|
|
- //force.linkDistance(120).charge(-200).size([w,h]).resume();
|
|
|
+ this.centerNodeX = this.w / 2;
|
|
|
+ this.centerNodeY = this.h / 2 + 5;
|
|
|
$("#entrelation-infovis").css({width:this.w,height:this.h});
|
|
|
//设置svg标签的宽度与高度
|
|
|
d3.select("svg").attr("width", this.w).attr("height", this.h);
|
|
|
$(".entrelation-controlls").removeClass("entrelation-controlls-fullscreen");
|
|
|
+ this.tickFlag = true;
|
|
|
+ this.force.resume();
|
|
|
if(document.exitFullscreen) {
|
|
|
document.exitFullscreen();
|
|
|
} else if (document.msExitFullscreen) {
|
|
@@ -445,15 +449,14 @@ Relation.prototype.initFullScreen = function(){
|
|
|
//重绘
|
|
|
var w=document.body.clientWidth;
|
|
|
var h=document.body.clientHeight;
|
|
|
- //if(w>1200){
|
|
|
- //w= 1200
|
|
|
- //}
|
|
|
+ thisClass.centerNodeX = w / 2;
|
|
|
+ thisClass.centerNodeY = h / 2 + 5;
|
|
|
$("#entrelation-infovis").css({width:w,height:h});
|
|
|
d3.select("svg").attr("width", w).attr("height", h);
|
|
|
$(".entrelation-controlls").addClass("entrelation-controlls-fullscreen");
|
|
|
- thisClass.force.linkDistance(h).charge(-700).size([w,h]).resume();
|
|
|
+ thisClass.tickFlag = true;
|
|
|
+ thisClass.force.start();
|
|
|
}
|
|
|
-
|
|
|
},timeout);
|
|
|
}else{
|
|
|
this.cancelFullScreen();
|
|
@@ -611,8 +614,12 @@ Relation.prototype.makeRelation = function(){
|
|
|
.nodes(this.data.nodes)
|
|
|
.links(this.data.links)
|
|
|
.size([this.w, this.h])
|
|
|
- .linkDistance(function(p){
|
|
|
- return Math.floor(Math.random()*60)+90;
|
|
|
+ .linkDistance(function(){
|
|
|
+ var distance = Math.floor(Math.random()*60)+100;
|
|
|
+ if(!this.defaultIsPattern){
|
|
|
+ distance += 50;
|
|
|
+ }
|
|
|
+ return distance;
|
|
|
})
|
|
|
.chargeDistance(600)
|
|
|
.charge(this.chargeVal)
|
|
@@ -676,6 +683,7 @@ Relation.prototype.makeRelation = function(){
|
|
|
.attr("y", "0")
|
|
|
.append("textPath")
|
|
|
.attr("class", "textpath")
|
|
|
+ .attr("text-anchor", "middle")
|
|
|
.attr("id", function(d) {
|
|
|
return 'text'+d.nodeId;
|
|
|
})
|
|
@@ -683,19 +691,16 @@ Relation.prototype.makeRelation = function(){
|
|
|
return '#'+d.nodeId;
|
|
|
})
|
|
|
.text(function(d) {
|
|
|
- var invacconam = new Number(d.invacconam);
|
|
|
+ var invacconam = parseInt(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+"万元";
|
|
|
+ return invacconam;
|
|
|
}else{
|
|
|
return "";
|
|
|
}
|
|
|
})
|
|
|
+ .style("font-size", "12px")
|
|
|
.style("fill", "#4e5051")
|
|
|
- .attr("startOffset", "20%")
|
|
|
+ .attr("startOffset", "24%")
|
|
|
.style("display", this.modleFlag?"none":"block");
|
|
|
|
|
|
this.lines.each(function (d,i){
|
|
@@ -859,10 +864,6 @@ Relation.prototype.makeTextBg = function(){
|
|
|
bounds.y2 += padding.top + padding.bottom;
|
|
|
|
|
|
var width = bounds.x2 - bounds.x1;
|
|
|
- if(d.type == "ce"){
|
|
|
- thisClass.centerNodeX = thisClass.w / 2;
|
|
|
- thisClass.centerNodeY = thisClass.h / 2 + 5;
|
|
|
- }
|
|
|
var height = bounds.y2 - bounds.y1;
|
|
|
node.select('rect')
|
|
|
.attr('x', bounds.x1)
|