Commit ee9e31fddd00084928811443359c4a5ac0fae050
1 parent
69b92326
线调
Showing
6 changed files
with
260 additions
and
315 deletions
src/main/resources/static/pages/control/line/css/lineControl.css
| ... | ... | @@ -208,29 +208,29 @@ |
| 208 | 208 | .card_wrap .line_chart{ |
| 209 | 209 | height: 100%; |
| 210 | 210 | padding: 0; |
| 211 | + border-top: 1px solid #DADADA; | |
| 211 | 212 | } |
| 212 | 213 | |
| 213 | 214 | .card_wrap .line_chart .top{ |
| 214 | - height: 64px; | |
| 215 | - background: linear-gradient(to right, #5384B9, #5e96d2, #5384B9); | |
| 216 | - border: 1px solid #DADADA; | |
| 215 | + height: 44px; | |
| 216 | + position: absolute; | |
| 217 | + left: 50%; | |
| 218 | + transform: translate(-50%, 0); | |
| 219 | + -webkit-transform: translate(-50%, 0); | |
| 217 | 220 | } |
| 218 | 221 | |
| 219 | 222 | .card_wrap .line_chart .top .center{ |
| 220 | - background: #FFFFFF; | |
| 221 | 223 | height: 100%; |
| 222 | 224 | font-size: 15px; |
| 223 | - color: #333; | |
| 225 | + color: #B9B9B9; | |
| 224 | 226 | padding: 10px 0px; |
| 225 | - font-family: 微软雅黑; | |
| 226 | - box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.16), 0 2px 10px 0 rgba(0, 0, 0, 0.12); | |
| 227 | - width: 190px; | |
| 227 | + width: auto; | |
| 228 | 228 | float: left; |
| 229 | + background: transparent; | |
| 229 | 230 | } |
| 230 | 231 | |
| 231 | 232 | .card_wrap .line_chart .top .center strong{ |
| 232 | - color: #336BB7; | |
| 233 | - font-size: 18px; | |
| 233 | + font-size: 30px; | |
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | .card_wrap .line_chart .top .left |
| ... | ... | @@ -358,23 +358,35 @@ |
| 358 | 358 | |
| 359 | 359 | /* svg 样式 */ |
| 360 | 360 | .line_chart svg{ |
| 361 | - background: #fdfdfd; | |
| 362 | - height: calc(100% - 70px); | |
| 363 | - margin: 18px 0 0 0; | |
| 361 | + height: 100%; | |
| 362 | + margin: 0; | |
| 363 | + z-index: 1; | |
| 364 | + position: absolute; | |
| 365 | + top: 0; | |
| 366 | + left: 0; | |
| 364 | 367 | } |
| 365 | -.station_circle{ | |
| 368 | +/* .station_circle{ | |
| 366 | 369 | fill: #FFFFFF; |
| 367 | 370 | r: 7.6; |
| 368 | -} | |
| 371 | +} */ | |
| 369 | 372 | |
| 370 | -.up_station_circle_inside{ | |
| 371 | - fill: #5e96d2; | |
| 373 | +.up_place{ | |
| 374 | + fill: red; | |
| 372 | 375 | r: 5; |
| 373 | 376 | } |
| 374 | 377 | |
| 375 | -.down_station_circle_inside{ | |
| 378 | +.up_station_circle{ | |
| 379 | + fill: #5e96d2; | |
| 380 | + r: 6; | |
| 381 | + stroke: #fff; | |
| 382 | + stroke-width: 3; | |
| 383 | +} | |
| 384 | + | |
| 385 | +.down_station_circle{ | |
| 376 | 386 | fill: #c92121; |
| 377 | - r: 5; | |
| 387 | + r: 6; | |
| 388 | + stroke: #fff; | |
| 389 | + stroke-width: 3; | |
| 378 | 390 | } |
| 379 | 391 | |
| 380 | 392 | .station_text{ |
| ... | ... | @@ -382,6 +394,14 @@ |
| 382 | 394 | letter-spacing: -2.6px; |
| 383 | 395 | } |
| 384 | 396 | |
| 397 | +.station_text.up{ | |
| 398 | + fill: #5e96d2; | |
| 399 | +} | |
| 400 | + | |
| 401 | +.station_text.down{ | |
| 402 | + fill: #c92121; | |
| 403 | +} | |
| 404 | + | |
| 385 | 405 | .station_text.end{ |
| 386 | 406 | fill: none; |
| 387 | 407 | stroke: #c92121; |
| ... | ... | @@ -396,10 +416,17 @@ |
| 396 | 416 | stroke-width: 7.4px; |
| 397 | 417 | stroke: #5e96d2; |
| 398 | 418 | } |
| 419 | + | |
| 399 | 420 | .down_path{ |
| 400 | 421 | stroke-width: 7.4px; |
| 401 | 422 | stroke: #c92121; |
| 402 | 423 | } |
| 424 | + | |
| 425 | +.up_path.arc, | |
| 426 | +.down_path.arc{ | |
| 427 | + fill: none; | |
| 428 | +} | |
| 429 | + | |
| 403 | 430 | .up-circle-none{ |
| 404 | 431 | fill: #5e96d2; |
| 405 | 432 | r: 3; | ... | ... |
src/main/resources/static/pages/control/line/index.html
| ... | ... | @@ -64,18 +64,18 @@ |
| 64 | 64 | </div> |
| 65 | 65 | <div class="portlet-body" id="top-tabs-wrap" > |
| 66 | 66 | <ul class="nav nav-tabs" > |
| 67 | - <li class=""> | |
| 67 | + <li class="active"> | |
| 68 | 68 | <a href="#tab_home" data-toggle="tab" aria-expanded="true" style="padding: 10px 15px;"> |
| 69 | 69 | <i class="fa fa-home"></i> 主页 |
| 70 | 70 | </a> |
| 71 | 71 | </li> |
| 72 | - <li class="active"><a href="#tab_map" data-toggle="tab" style="padding: 10px 15px;" | |
| 72 | + <li class=""><a href="#tab_map" data-toggle="tab" style="padding: 10px 15px;" | |
| 73 | 73 | aria-expanded="false"><i class="fa fa-map"></i> 地图 </a></li> |
| 74 | 74 | </ul> |
| 75 | 75 | |
| 76 | 76 | <div class="tab-content" style="padding: 5px;overflow-y: auto;"> |
| 77 | - <div class="tab-pane fade" id="tab_home" ></div> | |
| 78 | - <div class="tab-pane fade active in" id="tab_map" style="position: relative;"></div> | |
| 77 | + <div class="tab-pane fade active in" id="tab_home" ></div> | |
| 78 | + <div class="tab-pane fade" id="tab_map" style="position: relative;"></div> | |
| 79 | 79 | <div class="tab-pane fade" id="tab_line">单线路调度</div> |
| 80 | 80 | </div> |
| 81 | 81 | </div> | ... | ... |
src/main/resources/static/pages/control/line/js/data.js
| ... | ... | @@ -127,7 +127,7 @@ var _data = (function(){ |
| 127 | 127 | }else{ |
| 128 | 128 | for(var t = j; t < dIndex - 1; t++){ |
| 129 | 129 | var temp = down[t].station; |
| 130 | - data.push({name: ['',temp.stationName], type:1, id: [-1, temp.stationCod]}); | |
| 130 | + data.push({name: [temp.stationName], type:1, id: [temp.stationCod]}); | |
| 131 | 131 | } |
| 132 | 132 | //delete |
| 133 | 133 | down.splice(j, dIndex - 1 - j); |
| ... | ... | @@ -146,11 +146,11 @@ var _data = (function(){ |
| 146 | 146 | |
| 147 | 147 | if(first.type == 0 |
| 148 | 148 | && sec.type == 1){ |
| 149 | - data.splice(s, 2, {name: [first['name'][0],sec['name'][1]], type:3, id: [first['id'][0],sec['id'][1]]}); | |
| 149 | + data.splice(s, 2, {name: [first['name'][0],sec['name'][0]], type:3, id: [first['id'][0],sec['id'][0]]}); | |
| 150 | 150 | len --; |
| 151 | 151 | } |
| 152 | 152 | else if(first.type == 1 && sec.type == 0){ |
| 153 | - data.splice(s, 2, {name: [first['name'][1],sec['name'][0]], type:3, id: [first['id'][1],sec['id'][0]]}); | |
| 153 | + data.splice(s, 2, {name: [first['name'][0],sec['name'][0]], type:3, id: [first['id'][0],sec['id'][0]]}); | |
| 154 | 154 | len --; |
| 155 | 155 | } |
| 156 | 156 | } | ... | ... |
src/main/resources/static/pages/control/line/js/drawSvg.js
| 1 | 1 | /** |
| 2 | 2 | * 画线路svg 图 |
| 3 | -* | |
| 4 | -* type: 0 上行站点 1 下行站点 2 上下行共有 3 合并不同站点 | |
| 3 | +* type: 0 上行站点 1 下行站点 2 上下行共有 3 不同名合并 | |
| 5 | 4 | */ |
| 6 | - | |
| 7 | 5 | var drawSvg = (function(){ |
| 8 | 6 | |
| 9 | - //顶部距离 | |
| 10 | - var mTop = 21; | |
| 11 | - //上下行之间高度 | |
| 12 | - var h = 132; | |
| 7 | + var mt = 81//顶部距离 | |
| 8 | + ,p = 132//上下行之间的间隔 | |
| 9 | + ,x = d3.scale.linear() | |
| 10 | + ,w; | |
| 13 | 11 | |
| 14 | - var xScale; | |
| 15 | - var drawSvgObject = { | |
| 16 | - init: function(data, container){ | |
| 17 | - var stations = data; | |
| 18 | - var svg = d3.selectAll('#' + container).append('svg').attr('width', | |
| 19 | - '100%').attr('opacity', 0), | |
| 20 | - w = $('.line_chart:first').width(); | |
| 21 | - | |
| 22 | - var dLen = stations.length; | |
| 23 | - | |
| 24 | - //站点太多 | |
| 25 | - var ms = w / 42; | |
| 26 | - if(ms < dLen){ | |
| 27 | - for(var i = 0; i < dLen - ms; i ++){ | |
| 28 | - //要被清理的站点 | |
| 29 | - var rem = stations[i + 2]; | |
| 30 | - stations.splice(i + 2, 1); | |
| 31 | - | |
| 32 | - //设置哪些点需要虚线连接 | |
| 33 | - var prev = stations[i + 1]; | |
| 34 | - prev.clear = rem.type + 10; | |
| 35 | - } | |
| 36 | - dLen = stations.length; | |
| 37 | - } | |
| 38 | - var indent = w / 12 - (dLen * 2) - 2; | |
| 39 | - | |
| 40 | - //横向比例尺 -根据svg的宽度平均分布站点 | |
| 41 | - xScale = d3.scale.linear().domain([ 0, dLen]) | |
| 42 | - .range([ indent, w]); | |
| 43 | - | |
| 44 | - $.each(stations, function(i, d) { | |
| 45 | - d.cx = xScale(i); | |
| 46 | - }); | |
| 47 | - | |
| 48 | - $('#' + container).find('.text-load').remove(); | |
| 49 | - svg.transition().duration(1000).attr('opacity', 1); | |
| 50 | - //线 | |
| 51 | - drawRoutePath(svg, stations); | |
| 52 | - //点 | |
| 53 | - drawStationCircle(svg, stations); | |
| 54 | - //两端弧线 | |
| 55 | - brackets(svg); | |
| 56 | - //字 | |
| 57 | - drawText(svg, stations); | |
| 58 | - //修正位置 | |
| 59 | - adjustTwoName(svg); | |
| 60 | - } | |
| 61 | - }; | |
| 62 | - | |
| 63 | - var upLine = d3.svg.line().x(function(d) { | |
| 64 | - return d.cx; | |
| 65 | - }).y(function(d) { | |
| 66 | - return mTop; | |
| 67 | - }); | |
| 68 | - | |
| 69 | - var downLine = d3.svg.line().x(function(d) { | |
| 70 | - return d.cx; | |
| 71 | - }).y(function(d) { | |
| 72 | - return mTop + h; | |
| 73 | - }); | |
| 12 | + var upStation = function(value){ | |
| 13 | + return value.type != 1 ; | |
| 14 | + } | |
| 74 | 15 | |
| 75 | - var line = d3.svg.line().x(function(d) { | |
| 76 | - return d.attr('cx'); | |
| 77 | - }).y(function(d) { | |
| 78 | - return d.attr('cy'); | |
| 79 | - }); | |
| 16 | + var downStation = function(value){ | |
| 17 | + return value.type != 0; | |
| 18 | + } | |
| 80 | 19 | |
| 81 | - var circleClass = function(d, type, c){ | |
| 82 | - if(d.type == type){ | |
| 83 | - if(type == 1){ | |
| 84 | - c = 'up-circle-none'; | |
| 85 | - } | |
| 86 | - else{ | |
| 87 | - c = 'down-circle-none'; | |
| 88 | - } | |
| 89 | - } | |
| 90 | - return c; | |
| 20 | + var textY = function(d){ | |
| 91 | 21 | } |
| 92 | 22 | |
| 93 | - var getText = function(t){ | |
| 94 | - if (t.length > 7) { | |
| 95 | - return t.substring(0, 7) + '·'; | |
| 96 | - } | |
| 97 | - return t; | |
| 23 | + var upLine = d3.svg.line().x(function(d) { | |
| 24 | + return d.cx; | |
| 25 | + }).y(function(){return mt}); | |
| 26 | + | |
| 27 | + var downLine = d3.svg.line().x(function(d) { | |
| 28 | + return d.cx; | |
| 29 | + }).y(function(){return mt + p}); | |
| 30 | + | |
| 31 | + var cx = function(d, i){ | |
| 32 | + return x(i); | |
| 98 | 33 | } |
| 99 | 34 | |
| 100 | - //画圆点 | |
| 101 | - var drawStationCircle = function(svg, stations){ | |
| 102 | - | |
| 103 | - //上行 | |
| 104 | - svg.append('g').selectAll('circle').data(stations).enter().append('circle') | |
| 105 | - .attr('cy', mTop) | |
| 106 | - .attr('class', function(d){return circleClass(d, 1, 'station_circle')}) | |
| 107 | - .attr('cx', function(d, i) { | |
| 108 | - return d.cx; | |
| 109 | - }); | |
| 110 | - | |
| 111 | - svg.append('g').selectAll('circle').data(stations).enter().append('circle') | |
| 112 | - .attr('class', function(d, i){ | |
| 113 | - var classzz = circleClass(d, 1, 'up_station_circle_inside'); | |
| 114 | - if(i == 0) | |
| 115 | - classzz += ' start'; | |
| 116 | - else if(i == stations.length - 1) | |
| 117 | - classzz += ' end'; | |
| 118 | - | |
| 119 | - return classzz; | |
| 35 | + var drawSvgObject = { | |
| 36 | + init: function(data, container){ | |
| 37 | + w = $('.line_chart:first').width(); | |
| 38 | + var svg = d3.select('#' + container).append('svg') | |
| 39 | + .attr('width', w).attr('opacity', 0) | |
| 40 | + ,dLen = data.length; | |
| 41 | + | |
| 42 | + x.range([ 50 , w - 10]).domain([ 0, dLen]); | |
| 43 | + | |
| 44 | + //上行线条 path | |
| 45 | + svg.append('path') | |
| 46 | + .attr('d', function(){ | |
| 47 | + return upLine([{cx: x(0)}, {cx: x(dLen - 1)}]); | |
| 120 | 48 | }) |
| 121 | - .attr('cy', mTop) | |
| 122 | - .attr('id', function(d){ | |
| 123 | - var id = d.id[0]; | |
| 124 | - return id; | |
| 49 | + .attr('class', 'up_path'); | |
| 50 | + | |
| 51 | + //下行线条 path | |
| 52 | + svg.append('path') | |
| 53 | + .attr('d', function(){ | |
| 54 | + return downLine([{cx: x(0)}, {cx: x(dLen - 1)}]); | |
| 125 | 55 | }) |
| 126 | - .attr('cx', function(d, i) { | |
| 127 | - return d.cx; | |
| 128 | - }); | |
| 129 | - | |
| 130 | - //下行 | |
| 131 | - svg.append('g').selectAll('circle').data(stations).enter().append('circle') | |
| 132 | - .attr('class', function(d){return circleClass(d, 0, 'station_circle')}) | |
| 133 | - .attr('cy', mTop + h) | |
| 134 | - .attr('cx', function(d, i) { | |
| 135 | - return d.cx; | |
| 136 | - }); | |
| 137 | - svg.append('g').selectAll('circle').data(stations).enter().append('circle') | |
| 56 | + .attr('class', 'down_path'); | |
| 57 | + | |
| 58 | + //左弧线 path | |
| 59 | + svg.append('path') | |
| 60 | + .attr('d', function(){ | |
| 61 | + var cx = x(0) - 8 | |
| 62 | + ,cy = mt + 5 | |
| 63 | + ,arc = cx - 18; | |
| 64 | + return 'M' + cx + ',' + cy + ' C' + arc + ',' + (cy + 5) + ' ' + arc + ',' + (cy + p - 13) + ' ' + cx + ',' + (cy + p - 8); | |
| 65 | + }) | |
| 66 | + .attr('class', 'up_path arc'); | |
| 67 | + | |
| 68 | + //右弧线 path | |
| 69 | + svg.append('path') | |
| 70 | + .attr('d', function(){ | |
| 71 | + var cx = x(dLen - 1) + 8 | |
| 72 | + ,cy = mt + 5 | |
| 73 | + ,arc = cx + 18; | |
| 74 | + return 'M' + cx + ',' + cy + ' C' + arc + ',' + (cy + 5) + ' ' + arc + ',' + (cy + p - 13) + ' ' + cx + ',' + (cy + p - 8); | |
| 75 | + }) | |
| 76 | + .attr('class', 'down_path arc'); | |
| 77 | + | |
| 78 | + var g = svg.append('g').selectAll('g') | |
| 79 | + .data(data) | |
| 80 | + .enter() | |
| 81 | + .append('g').attr('class', 'item'); | |
| 82 | + | |
| 83 | + //上行站点 circle | |
| 84 | + g.append('circle') | |
| 85 | + .attr('class', function(d){ | |
| 86 | + if(d.type != 1) | |
| 87 | + return 'up_station_circle'; | |
| 88 | + }) | |
| 89 | + .attr('cx', cx) | |
| 90 | + .attr('cy', mt); | |
| 91 | + | |
| 92 | + //站点名称 text | |
| 93 | + g.append('text') | |
| 138 | 94 | .attr('class', function(d, i){ |
| 139 | - var classzz = circleClass(d, 0, 'down_station_circle_inside'); | |
| 95 | + var c = 'station_text'; | |
| 140 | 96 | if(i == 0) |
| 141 | - classzz += ' start'; | |
| 142 | - else if(i == stations.length - 1) | |
| 143 | - classzz += ' end'; | |
| 144 | - | |
| 145 | - return classzz; | |
| 97 | + c += ' start'; | |
| 98 | + else if(i == dLen - 1) | |
| 99 | + c += ' end'; | |
| 100 | + if(d.type == 3) | |
| 101 | + c += ' up'; | |
| 102 | + return c; | |
| 146 | 103 | }) |
| 147 | - .attr('cy', mTop + h) | |
| 148 | - .attr('cx', function(d, i) { | |
| 149 | - return d.cx; | |
| 104 | + .text(function(d){ | |
| 105 | + return d.type==3 ? d.name[0] : d.name; | |
| 150 | 106 | }) |
| 151 | - .attr('id', function(d){ | |
| 152 | - var id = d.id[1]; | |
| 153 | - return id; | |
| 154 | - }); | |
| 155 | - } | |
| 156 | - | |
| 157 | - var brackets = function(svg){ | |
| 158 | - //左括号 | |
| 159 | - svg.append('g').append('path') | |
| 160 | - .attr('d', function(){ | |
| 161 | - var up = svg.select('.up_station_circle_inside.start') | |
| 162 | - ,down = svg.select('.down_station_circle_inside.start'); | |
| 163 | - | |
| 164 | - var upX = parseInt(up.attr('cx')) -5 | |
| 165 | - , upY = parseInt(up.attr('cy')) + 8 | |
| 166 | - , downX = parseInt(down.attr('cx')) -5 | |
| 167 | - , downY = parseInt(down.attr('cy')) -8 | |
| 168 | - ,arc = (upX - 18); | |
| 169 | - return 'M' + upX + ',' + upY + ' C' + arc + ',' + (upY + 5) + ' ' + arc + ',' + (downY - 5) + ' ' + downX + ',' + downY; | |
| 170 | - }) | |
| 171 | - .attr('class', 'up_path') | |
| 172 | - .attr('fill', 'none'); | |
| 107 | + .attr('x', function(d, i){return (d.type==3?(x(i) - 8):x(i))}) | |
| 108 | + .attr('y', mt + 10); | |
| 173 | 109 | |
| 174 | - //右括号 | |
| 175 | - svg.append('g').append('path') | |
| 176 | - .attr('d', function(){ | |
| 177 | - var up = svg.select('.up_station_circle_inside.end') | |
| 178 | - ,down = svg.select('.down_station_circle_inside.end'); | |
| 179 | - | |
| 180 | - var upX = parseInt(up.attr('cx')) + 5 | |
| 181 | - , upY = parseInt(up.attr('cy')) + 8 | |
| 182 | - , downX = parseInt(down.attr('cx')) + 5 | |
| 183 | - , downY = parseInt(down.attr('cy')) -8 | |
| 184 | - ,arc = (upX + 18); | |
| 185 | - return 'M' + upX + ',' + upY + ' C' + arc + ',' + (upY + 5) + ' ' + arc + ',' + (downY - 5) + ' ' + downX + ',' + downY; | |
| 186 | - }) | |
| 187 | - .attr('class', 'down_path') | |
| 188 | - .attr('fill', 'none'); | |
| 189 | - } | |
| 190 | - | |
| 191 | - //画线条 | |
| 192 | - var drawRoutePath = function(svg, stations){ | |
| 193 | - //上下行拆分数组 | |
| 194 | - var upArray = [], downArray = []; | |
| 195 | - $.each(stations, function(i, st){ | |
| 196 | - if(st.type == 0) | |
| 197 | - upArray.push(st); | |
| 198 | - else if(st.type == 1) | |
| 199 | - downArray.push(st); | |
| 200 | - else if(st.type == 2){ | |
| 201 | - upArray.push(st); | |
| 202 | - downArray.push(st); | |
| 203 | - } | |
| 204 | - }); | |
| 205 | - | |
| 206 | - //上行线条 | |
| 207 | - svg.append('g').selectAll('path') | |
| 208 | - .data(upArray.slice(0, upArray.length - 1)).enter().append('path') | |
| 209 | - .attr('d', function(d, i) { | |
| 210 | - return upLine([ d, upArray[i + 1] ]); | |
| 211 | - }) | |
| 212 | - .attr('class', 'up_path') | |
| 213 | - .attr('stroke-dasharray', function(d){ | |
| 214 | - if(d.clear == 10 || d.clear == 12){ | |
| 215 | - $(this).css('stroke-width', '5px'); | |
| 216 | - return '2,1'; | |
| 217 | - } | |
| 218 | - return 0; | |
| 219 | - }); | |
| 220 | - | |
| 221 | - //下行线条 | |
| 222 | - svg.append('g').selectAll('path') | |
| 223 | - .data(downArray.slice(0, downArray.length - 1)).enter().append('path') | |
| 224 | - .attr('d', function(d, i) { | |
| 225 | - return downLine([ d, downArray[i + 1] ]); | |
| 110 | + //下行站点 | |
| 111 | + g.select(function(d){return d.type!=0?this:null}) | |
| 112 | + .append('circle') | |
| 113 | + .attr('class', function(d){ | |
| 114 | + if(d.type != 0) | |
| 115 | + return 'down_station_circle'; | |
| 116 | + }) | |
| 117 | + .attr('cx', cx) | |
| 118 | + .attr('cy', mt + p); | |
| 119 | + | |
| 120 | + //上下行不同名(异站合并) | |
| 121 | + g.select(function(d){return d.type==3?this:null}) | |
| 122 | + .append('text') | |
| 123 | + .attr('class', 'station_text down') | |
| 124 | + .text(function(d){return d.name[1]}) | |
| 125 | + .attr('x', function(d, i){return x(i) + 8;}) | |
| 126 | + .attr('y', mt + 10); | |
| 127 | + | |
| 128 | + /** | |
| 129 | + * --------------- 文字居中啊,长度截断啊处理一下 ---------------------- | |
| 130 | + */ | |
| 131 | + svg.selectAll('text') | |
| 132 | + .attr('transform', function(d, i){ | |
| 133 | + var len = $(this).text().length; | |
| 134 | + return 'translate(0,' + (len < 7?(7 - len) * 8:0) + ')'; | |
| 226 | 135 | }) |
| 227 | - .attr('class', 'down_path') | |
| 228 | - .attr('stroke-dasharray', function(d){//虚线 | |
| 229 | - if(d.clear == 11 || d.clear == 12){ | |
| 230 | - $(this).css('stroke-width', '5px'); | |
| 231 | - return '2,1'; | |
| 136 | + .text(function(){ | |
| 137 | + var t = $(this).text() | |
| 138 | + len = t.length; | |
| 139 | + if(len > 7){ | |
| 140 | + $(this).data('fullname', t); | |
| 141 | + return t.substring(0, 7); | |
| 232 | 142 | } |
| 233 | - return 0; | |
| 234 | - }); | |
| 235 | - } | |
| 143 | + return t; | |
| 144 | + }); | |
| 145 | + | |
| 146 | + $(' .text-load', '#'+container).remove(); | |
| 147 | + svg.transition().duration(500).attr('opacity', 1); | |
| 148 | + | |
| 149 | + up(svg, data, g); | |
| 150 | + } | |
| 151 | + }; | |
| 236 | 152 | |
| 237 | - //写文字 | |
| 238 | - var drawText = function(svg, stations){ | |
| 239 | - svg.append('g').selectAll('text').data(stations).enter() | |
| 240 | - .append('text') | |
| 241 | - .attr('y', | |
| 242 | - function(d, i) { | |
| 243 | - var t; | |
| 244 | - if(d.type == 1) | |
| 245 | - t = d.name[1]; | |
| 246 | - else | |
| 247 | - t = d.name[0]; | |
| 248 | - return mTop + 5 + (h - (18 * (t.length > 7 ? 7 : t.length))) / 2; | |
| 249 | - }) | |
| 250 | - .attr('class', function(d, i){ | |
| 251 | - var classz = 'station_text'; | |
| 252 | - if(i == 0) | |
| 253 | - classz += ' start'; | |
| 254 | - else if(i == stations.length - 1) | |
| 255 | - classz += ' end'; | |
| 256 | - return classz; | |
| 257 | - }) | |
| 258 | - .text(function(d){ | |
| 259 | - if(d.type == 1) | |
| 260 | - t = d.name[1]; | |
| 261 | - else | |
| 262 | - t = d.name[0]; | |
| 153 | + //更新 | |
| 154 | + function up(svg, data, g){ | |
| 155 | + /** | |
| 156 | + * ------------- 抽站 -------------------------------- | |
| 157 | + */ | |
| 158 | + var ms = w / 37 | |
| 159 | + ,dLen = data.length; | |
| 160 | + if(ms < dLen){ | |
| 161 | + var rs = dLen - ms | |
| 162 | + ,s = parseInt(dLen / 2 - rs) | |
| 163 | + ,e = (rs + s) * 2; | |
| 263 | 164 | |
| 264 | - if(d.type == 3) | |
| 265 | - $(this).attr('type', 3).attr('downName', d.name[1]); | |
| 266 | - return getText(t); | |
| 267 | - }) | |
| 268 | - .attr('x', function(d, i) { | |
| 269 | - return xScale(i); | |
| 270 | - }); | |
| 165 | + var rsEmes = []; | |
| 166 | + //中间开始,隔站抽 | |
| 167 | + for(;s < e; s +=2) | |
| 168 | + rsEmes.push(g[0][s]); | |
| 169 | + | |
| 170 | + var i = 0; | |
| 171 | + (function(){ | |
| 172 | + var f = arguments.callee; | |
| 173 | + if(i >= rsEmes.length){ | |
| 174 | + upPosi(svg) | |
| 175 | + } | |
| 176 | + | |
| 177 | + $(rsEmes[i]).fadeOut(30, function(){ | |
| 178 | + $(this).remove(); | |
| 179 | + i ++; | |
| 180 | + f(); | |
| 181 | + }); | |
| 182 | + })(); | |
| 183 | + } | |
| 271 | 184 | } |
| 272 | 185 | |
| 273 | - var adjustTwoName = function(svg){ | |
| 274 | - //上下行不同名 | |
| 275 | - var lastG = svg.append('g'); | |
| 276 | - $.each($('.station_text[type=3]'), function(i, obj){ | |
| 277 | - var x = parseInt($(obj).attr('x')) | |
| 278 | - ,diff = 8; | |
| 279 | - | |
| 280 | - lastG.append('text') | |
| 281 | - .attr('y', function(){ | |
| 282 | - var t = $(obj).attr('downname'); | |
| 283 | - return mTop + 5 + (h - (18 * (t.length > 7 ? 7 : t.length))) / 2; | |
| 284 | - }) | |
| 285 | - .attr('class', 'station_text') | |
| 286 | - .attr('x', (x + diff)) | |
| 287 | - .attr('fill', 'red') | |
| 288 | - .text(getText($(obj).attr('downname'))); | |
| 186 | + function upPosi(svg){ | |
| 187 | + //重新等比例位置 | |
| 188 | + var gItems = svg.selectAll('g.item') | |
| 189 | + ,dLen = gItems[0].length; | |
| 190 | + x.domain([ 0, dLen]); | |
| 191 | + gItems.select(function(d, i){ | |
| 192 | + var ts = $(this).find('text') | |
| 193 | + ,xv = x(i); | |
| 194 | + if(ts.length == 2){ | |
| 195 | + xv = x(i) - 8; | |
| 196 | + d3.select(ts[1]) | |
| 197 | + .transition().duration(500)//过渡 | |
| 198 | + .attr('x', x(i) + 8); | |
| 199 | + } | |
| 200 | + d3.select(ts[0]) | |
| 201 | + .transition().duration(500)//过渡 | |
| 202 | + .attr('x', xv); | |
| 289 | 203 | |
| 290 | - $(obj).attr('fill', '#337AB7') | |
| 291 | - .removeAttr('type').removeAttr('downname') | |
| 292 | - .attr('x', x - diff); | |
| 204 | + d3.select(this).selectAll('circle') | |
| 205 | + .transition().duration(500)//过渡 | |
| 206 | + .attr('cx', x(i)); | |
| 293 | 207 | }); |
| 208 | + //缩线 | |
| 209 | + svg.select('path.up_path') | |
| 210 | + .transition().delay(500).duration(500)//过渡 | |
| 211 | + .attr('d', function(){ | |
| 212 | + return upLine([{cx: x(0)}, {cx: x(dLen - 1)}]); | |
| 213 | + }); | |
| 214 | + | |
| 215 | + svg.select('path.down_path') | |
| 216 | + .transition().delay(500).duration(500)//过渡 | |
| 217 | + .attr('d', function(){ | |
| 218 | + return downLine([{cx: x(0)}, {cx: x(dLen - 1)}]); | |
| 219 | + }); | |
| 220 | + | |
| 221 | + svg.select('path.down_path.arc') | |
| 222 | + .transition().delay(500).duration(500)//过渡 | |
| 223 | + .attr('d', function(){ | |
| 224 | + var cx = x(dLen - 1) + 8 | |
| 225 | + ,cy = mt + 5 | |
| 226 | + ,arc = cx + 18; | |
| 227 | + return 'M' + cx + ',' + cy + ' C' + arc + ',' + (cy + 5) + ' ' + arc + ',' + (cy + p - 13) + ' ' + cx + ',' + (cy + p - 8); | |
| 228 | + }); | |
| 294 | 229 | } |
| 295 | 230 | |
| 296 | 231 | return drawSvgObject; | ... | ... |
src/main/resources/static/pages/control/line/js/main.js
| ... | ... | @@ -41,9 +41,11 @@ |
| 41 | 41 | |
| 42 | 42 | //svg线路图 |
| 43 | 43 | $.each(lineArray, function(i, obj){ |
| 44 | - _data.queryStationRoute(obj.id, 'line_chart_' + obj.id , drawSvg.init); | |
| 44 | + _data.queryStationRoute( obj.id, 'line_chart_' + obj.id , drawSvg.init); | |
| 45 | 45 | }); |
| 46 | 46 | |
| 47 | + //_data.queryStationRoute( lineArray[2].id, 'line_chart_' + lineArray[2].id , drawSvg.init); | |
| 48 | + | |
| 47 | 49 | $('.line_chart .top .top-remark').slimscroll({ |
| 48 | 50 | height: '47px' |
| 49 | 51 | }); |
| ... | ... | @@ -60,16 +62,9 @@ setTimeout(function(){ |
| 60 | 62 | $('#top-tabs-wrap .nav-tabs').append(topTabs); |
| 61 | 63 | |
| 62 | 64 | //加载地图页数据 |
| 63 | - $('#tab_map').load('/pages/mapmonitor/real/real.html'); | |
| 65 | + //$('#tab_map').load('/pages/mapmonitor/real/real.html'); | |
| 64 | 66 | |
| 65 | 67 | |
| 66 | - var homeLoad = false; | |
| 67 | - $('a[href=#tab_home]').on('click', function(){ | |
| 68 | - if(homeLoad) | |
| 69 | - return; | |
| 70 | - | |
| 71 | - homeLoad = true; | |
| 72 | - homeObject.init(); | |
| 73 | - }); | |
| 68 | + homeObject.init(); | |
| 74 | 69 | }, 200) |
| 75 | 70 | }(); |
| 76 | 71 | \ No newline at end of file | ... | ... |
src/main/resources/static/pages/control/line/temps/home_tp.html
| ... | ... | @@ -66,20 +66,8 @@ |
| 66 | 66 | </div> |
| 67 | 67 | <div class="col-lg-8 line_chart" id="line_chart_{{lineObj.id}}"> |
| 68 | 68 | <div class="top"> |
| 69 | - <div class="left"> | |
| 70 | - <div class="top-remark"> | |
| 71 | - 应发未发:4 [05:20, 07:10]<br> | |
| 72 | - 待发班次:44 [12:50, 13:20, 13:40, 14:05, 14:35, 14:55, 15:04, 16:60, 15:04, 16:60] | |
| 73 | - </div> | |
| 74 | - </div> | |
| 75 | 69 | <div class="center"> |
| 76 | - <strong>{{lineObj.name}}</strong> 计划配车:0<br> 在运营:0 场内:0 | |
| 77 | - </div> | |
| 78 | - <div class="right"> | |
| 79 | - <div class="top-remark"> | |
| 80 | - 应发未发:0 [05:20, 07:10]<br> | |
| 81 | - 待发班次:18 [12:50, 13:20, 13:40, 14:05, 14:35, 14:55, 15:04, 16:60] | |
| 82 | - </div> | |
| 70 | + <strong>{{lineObj.name}}</strong> | |
| 83 | 71 | </div> |
| 84 | 72 | </div> |
| 85 | 73 | <p style="margin-top: 70px;" class="text-load">正在加载...</p> | ... | ... |