-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo6.html
557 lines (528 loc) · 20.6 KB
/
demo6.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>流程设计工具 d3.js</title>
<link href="https://cdn.bootcss.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" rel="stylesheet">
<link href="https://cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
<link href="https://cdn.bootcss.com/jqueryui/1.12.1/jquery-ui.min.css" rel="stylesheet">
<!--<link rel="stylesheet" type="text/css" href="index.css">-->
<script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdn.bootcss.com/popper.js/1.12.5/umd/popper.min.js"></script>
<script src="https://cdn.bootcss.com/bootstrap/4.0.0-beta/js/bootstrap.min.js"></script>
<script src="https://cdn.bootcss.com/jqueryui/1.12.1/jquery-ui.min.js"></script>
<script src="https://cdn.bootcss.com/d3/4.11.0/d3.min.js"></script>
<script src="https://cdn.bootcss.com/d3-transform/1.0.4/d3-transform.min.js"></script>
<style>
.left-wrapper {
width: 250px;
position: absolute;
top: 0px;
bottom: 0px;
left: 0px;
background: #f0f0f0;
border-right: solid 1px #e7e7e7;
}
.middle-wrapper {
position: absolute;
top: 0px;
bottom: 0px;
left: 250px;
right: 250px;
}
.right-wrapper {
position: absolute;
width: 250px;
top: 0px;
bottom: 0px;
right: 0px;
background: #f5f5f5;
border-left: solid 1px #e7e7e7;
}
.sidebar-nav,
.sidebar-nav ul {
list-style: none;
padding: 0px;
}
.sidebar-nav > li:nth-child(odd),
.sidebar-nav ul li:nth-child(odd) {
background: #f0f0f0;
}
.sidebar-nav > li:nth-child(even),
.sidebar-nav ul > li:nth-child(even) {
background: #fff;
}
.sidebar-nav li {
text-indent: 4px;
line-height: 30px;
}
.sidebar-nav li li {
text-indent: 15px;
}
.sidebar-nav li li li {
text-indent: 25px;
}
.sidebar-nav li a {
display: block;
text-decoration: none;
color: #333;
}
.sidebar-nav li.active a {
background-color: #3e99ff;
}
.sidebar-nav li a > i + span {
margin-left: 3px;
}
.sidebar-nav li a:hover {
text-decoration: none;
background: rgba(255, 255, 255, 0.2);
}
.sidebar-nav li a:active, .sidebar-nav li a:focus {
text-decoration: none;
}
.middle-wrapper h4,
.right-wrapper h4 {
font-size: 1em;
height: 40px;
border-bottom: solid 1px #e7e7e7;
text-align: center;
line-height: 40px
}
.bpmn .node rect {
width: 180px;
height: 36px;
cursor: pointer;
stroke: #333;
stroke-width: 2;
fill: #fff;
}
.bpmn .node.active rect,
.bpmn .node.active circle {
stroke: lightblue;
}
.bpmn .node circle {
stroke: #333;
stroke-width: 2px;
/*fill: #fff;*/
cursor: crosshair;
}
.bpmn .node circle.end {
fill: orange;
}
.bpmn .cable {
stroke: #333;
stroke-width: 2px;
fill: none;
cursor: pointer;
}
.bpmn .deleteLine {
cursor: pointer;
}
.bpmn .node .deleteNode {
cursor: pointer;
}
</style>
</head>
<body>
<div class="container-fuild">
<!--左侧栏-->
<div id="left-wrapper" class="left-wrapper">
<ul class="sidebar-nav">
<li>
<a class="open">
<i class="fa fa-folder-o"></i>
<span>源/目标</span>
</a>
<ul>
<li class="node" data-id="101">
<a href="">
<i class="fa fa-database"></i>
<span>读数据</span>
</a>
</li>
<li class="node" data-id="102">
<a href="">
<i class="fa fa-database"></i>
<span>写数据</span>
</a>
</li>
</ul>
</li>
<li>
<a>
<i class="fa fa-folder-o"></i>
<span>数据预处理</span>
</a>
<ul>
<li class="node" data-id="211">
<a href="">
<i class="fa fa-crosshairs" aria-hidden="true"></i>
<span>类型转换</span>
</a>
</li>
<li class="node" data-id="212">
<a href="">
<i class="fa fa-crosshairs" aria-hidden="true"></i>
<span>拆分</span>
</a>
</li>
<li class="node" data-id="213">
<a href="">
<i class="fa fa-crosshairs" aria-hidden="true"></i>
<span>缺失值填充</span>
</a>
</li>
<li class="node" data-id="214">
<a href="">
<i class="fa fa-crosshairs" aria-hidden="true"></i>
<span>归一化</span>
</a>
</li>
<li class="node" data-id="215">
<a href="">
<i class="fa fa-crosshairs" aria-hidden="true"></i>
<span>标准化</span>
</a>
</li>
</ul>
</li>
<li>
<a>
<i class="fa fa-folder-o"></i>
<span>特征工程</span>
</a>
</li>
<li>
<a>
<i class="fa fa-folder-o"></i>
<span>机器学习</span>
</a>
<ul>
<li>
<a>
<i class="fa fa-folder-o"></i>
<span>二分类</span>
</a>
<ul>
<li class="node" data-id="311">
<a href="">
<i class="fa fa-circle-o"></i>
<span>GBDT二分类</span>
</a>
</li>
<li class="node" data-id="312">
<a href="">
<i class="fa fa-circle-o"></i>
<span>PS-SMART</span>
</a>
</li>
<li class="node">
<a href="">
<i class="fa fa-circle-o"></i>
<span>线性支持向量机</span>
</a>
</li>
<li class="node">
<a href="">
<i class="fa fa-circle-o"></i>
<span>逻辑回归二分类</span>
</a>
</li>
</ul>
</li>
<li>
<a>
<i class="fa fa-folder-o"></i>
<span>聚类</span>
</a>
<ul>
<li class="node">
<a href="">
<i class="fa fa-circle-o"></i>
<span>K均值聚类</span>
</a>
</li>
</ul>
</li>
<li>
<a>
<i class="fa fa-folder-o"></i>
<span>回归</span>
</a>
<ul>
<li class="node">
<a href="">
<i class="fa fa-circle-o"></i>
<span>GBDT回归</span>
</a>
</li>
<li class="node">
<a href="">
<i class="fa fa-circle-o"></i>
<span>线性回归</span>
</a>
</li>
<li class="node">
<a href="">
<i class="fa fa-circle-o"></i>
<span>PS_SMART回归</span>
</a>
</li>
<li class="node">
<a href="">
<i class="fa fa-circle-o"></i>
<span>PS线性回归</span>
</a>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
<div class="middle-wrapper">
<h4>实验名称</h4>
<div id="idsw-bpmn" class="bpmn" style="position: relative; width: 100%; height: 100%;">
<svg width="100%" height="100%">
<defs>
<marker id="arrowhead" viewBox="0 0 10 10" refX="10" refY="5" markerWidth="6" markerHeight="6"
orient="auto">
<path d="M 0 0 L 10 5 L 0 10 z" stroke-width="0" stroke="#333"></path>
</marker>
<pattern id="deleteLine" width="100%" height="100%" patternContentUnits="objectBoundingBox">
<image width="1" height="1" xlink:href="./delete.png"/>
</pattern>
</defs>
</svg>
</div>
<div style="height: 40px; border-top: solid 1px #e7e7e7; text-align: center; line-height: 40px; position: absolute;bottom: 2px; width: 100%">
<a class="btn btn-link checkTreeCorrectBtn" href="javascript:;"><i class="fa fa-play-circle-o" aria-hidden="true"></i> 运行</a>
<a class="btn btn-link " href="javascript:;"><i class="fa fa-cloud-upload" aria-hidden="true"></i> 部署</a>
<a class="btn btn-link" href="javascript:;"><i class="fa fa-share-alt" aria-hidden="true"></i> 分享</a>
</div>
</div>
<div class="right-wrapper">
<h4>实验属性</h4>
</div>
</div>
</body>
<script src="./js/tree.js"></script>
<script>
$(function () {
var svg = d3.select("svg");
//根据数据集转换成图
// var testData = {
// "nodes": [{
// "id": 1554878411108,
// "dataId": "101",
// "x": 176,
// "y": 41,
// "text": "\n \n \n 读数据\n \n ",
// "childrenMsg": {
// "left": "1554878412588"
// },
// "inputs": 0,
// "outputs": 1
// }, {
// "id": 1554878412588,
// "dataId": "102",
// "x": 180,
// "y": 179,
// "text": "\n \n \n 写数据\n \n ",
// "childrenMsg": {},
// "inputs": 1,
// "outputs": 0
// }],
// "lines": [{
// "id": "1554878414546",
// "outputPos": "0",
// "d": "M236,87 C236,133.5 271,133.5 271,180",
// "start": "60, 46",
// "end": "90, 0",
// "startId": "1554878411108",
// "startDataId": "101",
// "endId": "1554878412588",
// "endDataId": "102"
// }]
// };
var testData = {
"nodes": [{
"id": 1555034553053,
"dataId": "101",
"x": 395,
"y": 40,
"text": "\n \n \n 读数据\n \n ",
"childrenMsg": {
"left": "1555034555452",
"right": "1555034558236"
},
"inputs": 0,
"outputs": 1
}, {
"id": 1555034555452,
"dataId": "311",
"x": 169,
"y": 201,
"text": "\n \n \n GBDT二分类\n \n ",
"childrenMsg": {
"left": "1555034560460",
"right": "1555034562949"
},
"inputs": 1,
"outputs": 1
}, {
"id": 1555034558236,
"dataId": "312",
"x": 666,
"y": 179,
"text": "\n \n \n PS-SMART\n \n ",
"childrenMsg": {
"left": "1555034565244",
"right": "1555034567563"
},
"inputs": 1,
"outputs": 1
}, {
"id": 1555034560460,
"dataId": "211",
"x": 54,
"y": 395,
"text": "\n \n \n 类型转换\n \n ",
"childrenMsg": {},
"inputs": 1,
"outputs": 0
}, {
"id": 1555034562949,
"dataId": "212",
"x": 332,
"y": 371,
"text": "\n \n \n 拆分\n \n ",
"childrenMsg": {},
"inputs": 1,
"outputs": 0
}, {
"id": 1555034565244,
"dataId": "213",
"x": 660,
"y": 352,
"text": "\n \n \n 缺失值填充\n \n ",
"childrenMsg": {},
"inputs": 1,
"outputs": 0
}, {
"id": 1555034567563,
"dataId": "215",
"x": 976,
"y": 359,
"text": "\n \n \n 标准化\n \n ",
"childrenMsg": {},
"inputs": 1,
"outputs": 0
}],
"lines": [{
"id": "1555034570346",
"outputPos": "0",
"d": "M455,86 C455,142 256,142 256,198",
"start": "60, 46",
"end": "90, 0",
"startId": "1555034553053",
"startDataId": "101",
"endId": "1555034555452",
"endDataId": "311"
}, {
"id": "1555034572361",
"outputPos": "1",
"d": "M515,86 C515,133.5 755,133.5 755,181",
"start": "120, 46",
"end": "90, 0",
"startId": "1555034553053",
"startDataId": "101",
"endId": "1555034558236",
"endDataId": "312"
}, {
"id": "1555034575009",
"outputPos": "0",
"d": "M229,247 C229,321 145,321 145,395",
"start": "60, 46",
"end": "90, 0",
"startId": "1555034555452",
"startDataId": "311",
"endId": "1555034560460",
"endDataId": "211"
}, {
"id": "1555034577593",
"outputPos": "1",
"d": "M289,247 C289,308 422,308 422,369",
"start": "120, 46",
"end": "90, 0",
"startId": "1555034555452",
"startDataId": "311",
"endId": "1555034562949",
"endDataId": "212"
}, {
"id": "1555034579729",
"outputPos": "0",
"d": "M726,225 C726,289 748,289 748,353",
"start": "60, 46",
"end": "90, 0",
"startId": "1555034558236",
"startDataId": "312",
"endId": "1555034565244",
"endDataId": "213"
}, {
"id": "1555034583513",
"outputPos": "1",
"d": "M786,225 C786,290.5 1066,290.5 1066,356",
"start": "120, 46",
"end": "90, 0",
"startId": "1555034558236",
"startDataId": "312",
"endId": "1555034567563",
"endDataId": "215"
}]
};
tree.setWorkflow(testData);
tree.newTreeChart(svg, testData);
// 绑定拖拽
$('#left-wrapper .node').draggable({
helper: "clone",
addClass: false,
connectToSortable: "#idsw-bpmn",
start: function (e, ui) {
console.log("start: ", ui);
ui.helper.addClass("ui-draggable-helper");
},
stop: function (e, ui) {
console.log("stop: ", ui);
var node = {
id: new Date().getTime(),
dataId: ui.helper.attr('data-id'),
x: ui.position.left - 250,
y: ui.position.top - 40,
text: ui.helper.text(),
childrenMsg: {},
inputs: 1,
outputs: 2
};
if (node.dataId == 101) {
node.inputs = 0;
node.outputs = 1;
} else if (node.dataId == 102 || node.dataId == 211 || node.dataId == 212 || node.dataId == 213 || node.dataId == 214 || node.dataId == 215) {
node.inputs = 1;
node.outputs = 0;
} else {
node.inputs = 1;
node.outputs = 1;
}
// 记录在数据集中
tree.getWorkflow().nodes.push(node);
tree.addNode(svg, node);
}
});
//校验树的正确性
$(".checkTreeCorrectBtn").click(function () {
console.log("sql: ",tree.transformToSql());// (((211)311(212))101((213)312(215)))
});
});
</script>
</html>