-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUI_Design.html
More file actions
608 lines (511 loc) · 26.7 KB
/
UI_Design.html
File metadata and controls
608 lines (511 loc) · 26.7 KB
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
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="http://d3js.org/d3.v3.js" charset="utf-8"></script>
<script src="http://apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/0.14.3/ui-bootstrap-tpls.js"></script>
<script src="https://rawgit.com/rzajac/angularjs-slider/master/dist/rzslider.js"></script>
<link href="https://rawgit.com/rzajac/angularjs-slider/master/dist/rzslider.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="http://www.francescomalagrino.com/BootstrapPageGenerator/3/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet" type="text/css" media="all"/>
<style>
article {
padding: 0cm 0.5cm 0cm 0.6cm;
}
.scrollable {
overflow-x: scroll;
padding-top:40px;
border:1px solid #ddd;
border-radius:1px;
height:100%;
text-align: center;
}
.node {
stroke: #fff;
stroke-width: 1.5px;
}
.link {
stroke: #999;
stroke-opacity: .6;
}
.scrollable::-webkit-scrollbar {
height: 6px;
}
.scrollable::-webkit-scrollbar-track {
background-color:#f5f5f5;
-webkit-border-radius: 1em;
-moz-border-radius: 1em;
border-radius:1em;
}
.scrollable::-webkit-scrollbar-thumb {
border-radius: 8px;
background-color: #FFF;
background-image: -webkit-gradient(linear, 40% 0%, 75% 84%, from(#4D9C41), to(#19911D), color-stop(.6, #54DE5D));
-webkit-border-radius: 1em;
-moz-border-radius: 1em;
border-radius:1em;
}
</style>
</head>
<body ng-app="myApp" ng-controller="HomeController">
<div class="container-fluid">
<div class="row-fluid">
<div class="col-md-9">
<div class="row-fluid">
<div class="span12">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
面板标题
</h3>
</div>
<div class="panel-body scrollable">
<article id='pad'>
<rzslider id='SliderDate' rz-slider-model="range_slider_ticks_values.minValue" rz-slider-high="range_slider_ticks_values.maxValue" rz-slider-options="range_slider_ticks_values.options"></rzslider>
</article>
<stackgraph id='leftdiv'>
</stackgraph>
</div>
</div>
</div>
</div>
<div class="row-fluid">
<div class="span12">
<div class='scrollable' >
<forcegraph id='bottondiv', data='range_slider_ticks_values'>
</forcegraph>
</div>
</div>
</div>
</div>
<div class="col-md-3">
<h3>
玩家信息查询
</h3>
<form class="form-search">
<p>
玩家ID: <input class="input-medium search-query" type="text" /> <button class="btn" type="submit">查找</button>
</p>
</form>
</div>
</div>
</div>
</body>
</html>
<script>
var myApp = angular.module('myApp', ['rzModule', 'ui.bootstrap']);
myApp.controller('HomeController', function ($scope, $rootScope, $timeout, $modal){
$scope.range_slider_ticks_values = {
minValue: 1,
maxValue: 4,
options: {
ceil: 5,
floor: 0,
showTicksValues: true,
scale: 1,
translate: function(value) {
return '2015.1.' + (value+1);
}
}
};
});
myApp.directive('stackgraph', function(){
function link(scope, el, attr){
console.log('hello');
var DivWidth = document.getElementById('leftdiv');
var article = document.getElementById('pad');
//pad.style.paddingRight = -20;
distance = -(2300 - article.offsetWidth + 70);
ctext = "margin: 0cm " + distance + "px 0cm -0.3cm";
article.style.cssText = ctext;
console.log(article.style);
DivWidth.style.cssText = "margin-left: 0.6cm";
console.log(DivWidth.offsetWidth);
//var width = DivWidth.offsetWidth - 30;
var width = 2300;
var height = 300;
var lineData = [
[{x:0, y:14}, {x:5, y:10}, {x:10, y:30}, {x:15, y:50}, {x:20, y:20}, {x:25, y:25}],
[{x:0, y:10}, {x:5, y:5}, {x:10, y:10}, {x:15, y:10}, {x:20, y:15}, {x:25, y:5}],
[{x:0, y:20}, {x:5, y:15}, {x:10, y:5}, {x:15, y:20}, {x:20, y:30}, {x:25, y:10}],
[{x:0, y:10}, {x:5, y:20}, {x:10, y:10}, {x:15, y:15}, {x:20, y:5}, {x:25, y:15}]
];
var core = [
[7, 2, 10, 20, 5, 15],
[5, 1, 1, 3, 5, 1],
[10, 5, 1, 10, 10, 5],
[2, 12, 5, 11, 1, 13]
];
var core1 = [
[0.7, 0.2, 0.5, 0.5, 0.1, 0.8],
[0.5, 0.1, 0.1, 0.8, 0.1, 0.1],
[0.2, 0.1, 0.2, 0.2, 0.2, 0.2],
[0.7, 0.5, 0.3, 0.5, 0.8, 0.1]
];
var core2 = [
[0.7, 0.2, 0.5, 0.5, 0.1, 0.8],
[0.5, 0.1, 0.1, 0.8, 0.1, 0.1],
[0.2, 0.1, 0.2, 0.2, 0.2, 0.2],
[0.7, 0.5, 0.3, 0.5, 0.8, 0.1]
];
var axis_data = [[5, 0], [5, 105]];
var axis_data0 = [[0, 0], [0, 105]];
var axis_data1 = [[10, 0], [10, 105]];
var axis_data2 = [[15, 0], [15, 105]];
var axis_data3 = [[20, 0], [20, 105]];
var axis_data4 = [[25, 0], [25, 105]];
var PowerData1 = [{x:0, y:0.5}, {x:5, y:0.3}, {x:10, y:0.8}, {x:15, y:0.1},
{x:20, y:0.5}, {x:25, y:0.3}];
var PowerData2 = [{x:0, y:0.2}, {x:5, y:0.5}, {x:10, y:0.2}, {x:15, y:0.8},
{x:20, y:0.5}, {x:25, y:0.1}];
var lineData0 = [{x:0, y0:14, y1:10}, {x:5, y0:10, y1:5}, {x:10, y0:30, y1: 10},
{x:15, y0:50, y1:10}, {x:20, y0:20, y1:15}, {x:25, y0:25, y1:5}];
stack = d3.layout.stack().offset("silhouette");
a = stack(lineData);
var x = d3.scale.linear()
.domain([0,25])
.range([0, width]);
var color1 = d3.scale.linear()
.range(["#CFCFCF", "#CFCFCF"]);
var color2 = '#EE5C42';
var color = d3.scale.linear()
.range(["#EEC591", "#EE5C42"]);
var y = d3.scale.linear()
.domain([-10,120])
.range([height, 0]);
svg = d3.select(el[0]).append('svg');
var area = d3.svg.area()
.x(function(d) { return x(d.x); })
.y0(function(d) { return y(d.y0); })
.y1(function(d) { return y(d.y0 + d.y); })
.interpolate('cardinal');
svg.attr({width: width, height: height});
var area1 = d3.svg.area()
.x(function(d) { return x(d.x); })
.y0(function(d) { return y(d.y0); })
.y1(function(d) { return y(d.y1); })
.interpolate('cardinal');
svg.selectAll('path')
.data(a)
.enter().append('path')
.attr("d", area)
.style("fill", function() { return color1(Math.random()); });
//console.log(a);
renderSide(svg, a[0]);
renderSide(svg, a[1]);
renderSide(svg, a[2]);
renderSide(svg, a[3]);
renderAxis(svg, axis_data);
renderAxis(svg, axis_data0);
renderAxis(svg, axis_data1);
renderAxis(svg, axis_data2);
renderAxis(svg, axis_data3);
renderAxis(svg, axis_data4);
renderArea(svg, getCore(core1[0], a[0], 1, getSize(a[0], 0)));
renderArea(svg, getCore(core1[1], a[1], 1, getSize(a[1], 0)));
renderArea(svg, getCore(core1[2], a[2], 1, getSize(a[2], 0)));
renderArea(svg, getCore(core1[3], a[3], 1, getSize(a[3], 0)));
renderArea1(svg, getCore(core1[0], a[0], 2, getSize(a[0], 0)));
renderArea1(svg, addTran1(core1[1], core1[0], a[1], a[0], 2, getSize(a[1], 0), getSize(a[0], 0)));
renderArea1(svg, getCore(core1[2], a[2], 2, getSize(a[2], 0)));
renderArea1(svg, getCore(core1[3], a[3], 2, getSize(a[3], 0)));
//addTitle(svg, ' ', axis_data);
/*svg.append('path')
.attr("d", area1(lineData0))
.style("fill", function() { return color1(Math.random()); });*/
function getChange(d){
var c = [];
var begin = [];
var end = [];
var result = [];
for(var i = 0; i < d.length; i++){
var temp = [];
for(var j = 1; j < d[i].length; j++){
if(d[i][j] - d[i][j-1] > 0.2)
temp.push(1);
else if(d[i][j] - d[i][j-1] < -0.2)
temp.push(-1);
else
temp.push(0);
}
c.push(temp);
}
for(var i = 0; i < c[0].length; i++){
var begin_t = [];
var end_t = [];
for(var j = 0; j < c.length; j++){
if(c[j][i] == -1)
begin_t.push(j);
else if(c[j][i] == 1)
end_t.push(j)
}
if(begin_t.length == 0)
begin_t.push(-1);
if(end_t.length == 0)
end_t.push(-1);
begin.push(begin_t);
end.push(end_t);
}
result.push(begin);
result.push(end);
return result;
}
function addTran(t, s, d){
var lenth = d[0].length;
var begin = t[0];
var end = t[1];
var AreaSide = [];
for(var i = 0; i < lenth; i++){
if(begin[i].length == 1 && begin[i][0] == -1)
continue;
if(end[i])
if(i != 3){
var center = side[i].y0 + side[i].y / 2;
var top = center + d[i] / 2;
var buttom = center - d[i] / 2;
}
else{
var center = side0[i].y0 + side0[i].y / 2;
var top = center + d[i] / 2;
var buttom = center - d[i] / 2;
}
AreaSide.push(
{x: side[i].x,
y0: top,
y1: buttom}
);
}
//console.log(AreaSide);
return AreaSide;
}
function addTran1(d, d0, side, side0, cat, size, size0){
var lenth = side.length;
var AreaSide = [];
for(var i = 0; i < lenth; i++){
if(i != 3){
var center = side[i].y0 + side[i].y * cat / 4;
var top = center + size * (d[i] < 0.2 ? 0 : d[i]) / 2;
var buttom = center - size * (d[i] < 0.2 ? 0 : d[i]) / 2;
}
else{
var center = side0[i].y0 + side0[i].y * cat / 4;
var top = center + size0 * (d0[i] < 0.2 ? 0 : d0[i]) / 2;
var buttom = center - size0 * (d0[i] < 0.2 ? 0 : d0[i]) / 2;
}
AreaSide.push(
{x: side[i].x,
y0: top,
y1: buttom}
);
}
console.log(AreaSide);
return AreaSide;
}
function getSize(d, threshold){
var lenth = d.length;
var min = 100;
for(var i = 0; i < lenth; i++){
if(d[i].y >= threshold && d[i].y < min)
min = d[i].y;
}
min = min / 2;
//console.log(min);
return min;
}
function getCore(d, side, cat, size){
var lenth = side.length;
var AreaSide = [];
for(var i = 0; i < lenth; i++){
var center = side[i].y0 + side[i].y * cat / 4;
var top = center + size * (d[i] < 0.2 ? 0 : d[i]) / 2;
var buttom = center - size * (d[i] < 0.2 ? 0 : d[i]) / 2;
AreaSide.push(
{x: side[i].x,
y0: top,
y1: buttom}
);
}
//console.log(AreaSide);
return AreaSide;
}
function getSCore(d, side, side0){
var lenth = side.length;
var AreaSide = [];
for(var i = 0; i < lenth; i++){
if(i != 3){
var center = side[i].y0 + side[i].y / 2;
var top = center + d[i] / 2;
var buttom = center - d[i] / 2;
}
else{
var center = side0[i].y0 + side0[i].y / 2;
var top = center + d[i] / 2;
var buttom = center - d[i] / 2;
}
AreaSide.push(
{x: side[i].x,
y0: top,
y1: buttom}
);
}
//console.log(AreaSide);
return AreaSide;
}
function renderArea(s, d){
var color = d3.scale.linear()
.range(["#00EC00", "#00EC00"]);
var area = d3.svg.area()
.x(function(d) { return x(d.x); })
.y0(function(d) { return y(d.y0); })
.y1(function(d) { return y(d.y1); })
.interpolate('cardinal');
svg.append('path')
.attr("d", area(d))
.attr('stroke-dasharray', '5,5')
.style("fill", function() { return color(Math.random()); });
}
function renderArea1(s, d){
var color = d3.scale.linear()
.range(["#EE5C42", "#EE5C42"]);
var area = d3.svg.area()
.x(function(d) { return x(d.x); })
.y0(function(d) { return y(d.y0); })
.y1(function(d) { return y(d.y1); })
.interpolate('cardinal');
svg.append('path')
.attr("d", area(d))
.style("fill", function() { return color(Math.random()); });
}
function getSide(d){
var lenth = d.length;
var side = [];
for(var i = 0; i < lenth; i++){
temp = [d[i].x, d[i].y0];
side.push(temp);
}
console.log(side);
return side;
}
function renderSide(s, d){
var lineGenerator = d3.svg.line()
.x(function(d) { return x(d[0]); })
.y(function(d) { return y(d[1]); })
.interpolate('cardinal');
s.append('path').attr('d', lineGenerator(getSide(d)))
.attr('fill', 'none')
.attr("stroke", "white")
.attr('stroke-width', 2);
}
function renderAxis(s, d){
var lineGenerator = d3.svg.line()
.x(function(d) { return x(d[0]); })
.y(function(d) { return y(d[1]); });
s.append('path').attr('d', lineGenerator(d))
.attr('fill', 'none')
.attr("stroke", "black")
.attr('stroke-width', 5)
.attr('stroke-dasharray', '5,5');
console.log('a');
}
function addTitle(s, t, d){
s.append("text")
.text("2015.1.1")
.attr("class","title")
.attr("x",x(4.5))
.attr("y",y(-10))
.attr("font-family", "Times New Roman")
.attr("font-size", 20);
}
}
return {
link: link,
restrict: 'E',
scope: { data: '=' }
};
});
myApp.directive('forcegraph', function(){
function link(scope, el, attr){
var nodes = [ { name: "41035CCA31435" }, { name: "5163CCE671596" },
{ name: "3C25D3BA2326" }, { name: "5131004AC1511" },
{ name: "618E709481668" }, { name: "150DA8C31135" },
{ name: "4F7A892F2415" } ];
var edges = [ { source : 0 , target: 1 } , { source : 0 , target: 2 } ,
{ source : 0 , target: 3 } , { source : 1 , target: 4 } ,
{ source : 1 , target: 5 } , { source : 1 , target: 6 } ];
var nodes1 = [ { name: "41035CCA31433" }, { name: "5163CCE671596" },
{ name: "3C25D3BA2326" }, { name: "5131004AC1511" },
{ name: "618E709481668" }, { name: "150DA8C31135" },
{ name: "4F7A892F2415" } ];
var edges1 = [ { source : 1 , target: 3 } , { source : 0 , target: 2 } ,
{ source : 0 , target: 3 } , { source : 1 , target: 4 } ,
{ source : 1 , target: 5 } , { source : 1 , target: 6 } ];
var width = 1200;
var height = 600;
console.log('here');
console.log(scope);
data = scope.data;
scope.$watch('data', function(){
console.log(data.minValue + '-' + data.maxValue);
}, true);
var svg = d3.select(el[0])
.append("svg")
.attr("width",width)
.attr("height",height);
var force = d3.layout.force()
.nodes(nodes) //指定节点数组
.links(edges) //指定连线数组
.size([width,height]) //指定作用域范围
.linkDistance(150) //指定连线长度
.charge([-400]); //相互之间的作用力
force.start();
//添加连线
var svg_edges = svg.selectAll("line")
.data(edges)
.enter()
.append("line")
.style("stroke","#ccc")
.style("stroke-width",1);
var color = d3.scale.category20();
//添加节点
var svg_nodes = svg.selectAll("circle")
.data(nodes)
.enter()
.append("circle")
.attr("r",10)
.style("fill",function(d,i){
return color(i);
})
.call(force.drag); //使得节点能够拖动
//添加描述节点的文字
var svg_texts = svg.selectAll("text")
.data(nodes)
.enter()
.append("text")
.style("fill", "black")
.attr("dx", 20)
.attr("dy", 8)
.text(function(d){
return d.name;
});
force.on("tick", function(){ //对于每一个时间间隔
//更新连线坐标
svg_edges.attr("x1",function(d){ return d.source.x; })
.attr("y1",function(d){ return d.source.y; })
.attr("x2",function(d){ return d.target.x; })
.attr("y2",function(d){ return d.target.y; });
//更新节点坐标
svg_nodes.attr("cx",function(d){ return d.x; })
.attr("cy",function(d){ return d.y; });
//更新文字坐标
svg_texts.attr("x", function(d){ return d.x; })
.attr("y", function(d){ return d.y; });
});
}
return {
link: link,
restrict: 'E',
scope: { data: '=' }
};
});
</script>