1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
function circleTest(circledata1,period,Time,provinceId,keyBusinessId) {
/* var a=[], a1=[];
var id = 1;
for(var t=0;t<circledata1.length;t++){
var data2 = circledata1[t][1];
var data3 = circledata1[t][2];
if(data2 == "" || data2 == null){
id--;
}else{
var lowtime = getTimeUpperValue().valueOf(); //加入工单异常处理时长的限制
var uptime = getTimeLowerValue().valueOf();
if(lowtime == 0 && uptime == 0){
id = circledata1.length;
for(var r = 0 ;r <data2.length ; r++){
var b = [circledata1[t][0]], b1 = [circledata1[t][0]];
b.push(data2[r]);
b1.push(data3[r]);
a.push(b);
a1.push(b1);
}
}else{
for(var r = 0 ;r <data2.length ; r++){
data2[r] = parseFloat(data2[r]);
if(data2[r] < uptime && lowtime <= data2[r]){
if(a.length != 0 && a[a.length-1][0] != circledata1[t][0]){
id++;
}
var b = [circledata1[t][0]], b1 = [circledata1[t][0]];
b.push(data2[r]);
b1.push(data3[r]);
a.push(b);
a1.push(b1);
}
}
}
}
}*/
var a=[], a1=[];
var id = 1;
for(var t=0;t<circledata1.length;t++){
var data2 = circledata1[t][1];
//var data3 = circledata1[t][2];
if(data2 == "" || data2 == null){
id--;
}else{
var lowtime = getTimeUpperValue().valueOf(); //加入工单异常处理时长的限制
var uptime = getTimeLowerValue().valueOf();
if(lowtime == 0 && uptime == 0){
id = circledata1.length;
for(var r = 0 ;r <data2.length ; r++){
var b = [circledata1[t][0]], b1 = [circledata1[t][0]];
b.push(data2[r]);
//b1.push(data3[r]);
a.push(b);
//a1.push(b1);
}
}else{
for(var r = 0 ;r <data2.length ; r++){
data2[r] = parseFloat(data2[r]);
if(data2[r] < uptime && lowtime <= data2[r]){
if(a.length != 0 && a[a.length-1][0] != circledata1[t][0]){
id++;
}
var b = [circledata1[t][0]], b1 = [circledata1[t][0]];
b.push(data2[r]);
//b1.push(data3[r]);
a.push(b);
//a1.push(b1);
}
}
}
}
}
console.log("a:"+a);
var margin = {top: 30, right: 50, bottom: 70, left: 50};
var width =550 - margin.left - margin.right;
var height = 400 - margin.top - margin.bottom;
var padding = 20;
$("#circleDiv").html("");
var svg = d3.select("div#circleDiv").append("svg")
.attr("width", width + margin.left + margin.right)
.attr("height", height + margin.top + margin.bottom+60)
.attr("class", "box")
.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
var x = d3.scale.ordinal()
.domain( a.map(function(d) { return d[0]; } ) )
.rangeRoundBands([0 ,width-padding]);
var xAxis = d3.svg.axis()
.scale(x)
.orient("bottom").outerTickSize(0);
console.log("max"+d3.max(a,function (d){return Math.max(d[1]);}));
console.log("min:"+d3.min(a,function (d){return Math.min(d[1]);}));
// the y-axis
var y = d3.scale.linear()
.domain([d3.min(a,function (d){return Math.max(d[1]);})-1, d3.max(a,function (d){return Math.max(d[1]);})])
.range([height , 0]);
var yAxis = d3.svg.axis()
.scale(y)
.orient("left").outerTickSize(0);
// draw y axis
svg.append("g")
.attr("class", "y axis")
.call(yAxis);
// draw x axis
svg.append("g")
.attr("class", "x axis")
.attr("transform", "translate(0," + (height) + ")")
.call(xAxis)
.selectAll("text")
.style("text-anchor", "end")
.attr("dx", "-.8em")
.attr("dy", ".15em")
.attr("transform", function(d) {
return "translate(-5,0)rotate(-90)" ;});
/*.append("text") // text label for the x axis
.attr("x", (width/2) )
.attr("y", 30 )
.attr("dy", ".71em")
.style("text-anchor", "end")
.style("font-size", "16px")
.text("关键环节"); */
if(a == "" || a == null){
svg .append("text") // text label for the x axis
.attr("x", (width/2) )
.attr("y", (height/2) )
.attr("dy", ".71em")
.style("text-anchor", "end")
.style("font-size", "16px")
.text("暂无数据");
}else{
svg.selectAll("circle")
.data(a)
.enter()
.append("circle")
.attr("cx", function (d,i) { return x(d[0]); } )
.attr("cy", function(d,i) {
return y(d[1]);
})
.attr("r", 3)
.attr("transform", "translate("+(width-padding)/(id*2)+",0)");
svg.selectAll("circle").data(a).append("svg:title")
.text(function(d) { return d[0]+":"+d[1]; });
svg.selectAll("circle").data(a).style('cursor','pointer').on('click', function (d){
dialog_artDialog("异常点明细","<div id='circleDetail'><table id='circleTable' class='table table-hover table-striped' style='text-align:center;'></div>","1000px","500px");
var all = period+"&"+Time+"&"+provinceId +"&"+keyBusinessId +"&"+d;
circleDetailChart(all);
});
}
}
function Bind(period,Time,provinceId,keyBusinessId,keyLinkId,minValue){
var all = "?MultiType=2" //单省多环节箱体图
+"&province="+provinceId //省份id(单省)
+"&business="+keyBusinessId //业务id(单业务)
+"&link="+keyLinkId // 环节ID(多环节)
+"&linkName=-1" // 环节名称(单省单环节多时段箱体图只能显示名称)
+"&netelement="+"-1" //网元
+"&start="+period.split(",")[0] //开始日期
+"&end="+period.split(",")[1] //结束日期
+"&time_ids="+Time //时间段Id
+"&minValue="+minValue;
$.alax({
type : "get",
contentType : 'application/lson',
url : '../MonitorOperation/KeyLinkProcessAnalysis/outlier/'+all,
dataType : 'text',
/*async: false ,*/
beforeSend : function(data) {
},
success : function(data) {
for ( var i = 0; i < data.length; i++) {
if (data == '\"') {
data = data.replace("\"", "\'");
}
}
data = eval("(" + data + ")");
console.log("data:"+data);
console.log("data.length:"+data.length);
var circledata1=[];
var l=0;
for(var i = 0;i<data.length;i++){
var e = data[i];
circledata1[l]=[];
circledata1[l][0] = e[0];
for(var t = 1; t < e.length; t++){
if(circledata1[l][1] == "" || circledata1[l][1] == null){
circledata1[l][1]=[e[t]];
circledata1[l][2]=[e[t+1]];
}else{
circledata1[l][1].push(e[t]);
circledata1[l][2].push(e[t+1]);
}
}
l++;
}
outlierData = circledata1;
circleTest(outlierData,period,Time,provinceId,keyBusinessId);
$('#circleDiv').parent().parent().find('.loading').fadeOut("fast");//隐藏loading图片
}});
}