index.html 17.9 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
<link href="css/lineControl.css" rel="stylesheet" type="text/css" />
<div class="portlet light portlet-fullscreen" style="transition: all .5s ease;padding: 12px 5px 15px 5px;">
    <div class="portlet-title" style="padding: 20px 20px 7px 20px;">
        <div class="caption" >
			<i class="fa fa-life-ring" style="font-size: 22px"></i> <span
				class="caption-subject bold" style="font-size: 24px;">线路调度系统</span>
		</div>
        <div class="actions">
            <a class="btn btn-circle btn-icon-only btn-default fullscreen on" href="javascript:;" data-original-title="" title=""> </a>
        </div>
    </div>
    <div class="portlet-body">
		<ul class="nav nav-tabs" style="margin-left: 15px;margin-bottom: 20px;">
			<li class="active"><a href="#tab_home" data-toggle="tab"
				aria-expanded="true"> 主页 </a></li>
			<li class=""><a href="#tab_map" data-toggle="tab"
				aria-expanded="false"> 地图监控 </a></li>
				
				
			<li class=""><a href="#tab_85" data-toggle="tab"
				aria-expanded="false"> 85路 </a></li>
				
			
			<li class=""><a href="#tab_50" data-toggle="tab"
				aria-expanded="false"> 浦东50路 </a></li>	
		</ul>

		<div class="tab-content">
			<div class="tab-pane fade active in z-depth-1" id="tab_home" >
				<div class="row card_wrap" >
					<div class="col-lg-2 z-depth-2" >
						
						<div class="title">
							发往川沙客运站方向 
							<span class="badge" > 13 </span>
							<span class="help_text">上行</span>
						</div>
                            <table class="table table-striped table-bordered table-advance">
                                <colgroup>
									<col style="width: 79px;" />
									<col style="width: 78px;" />
									<col style="width: 75px;" />
									<col style="width: 57px;" />
									<col style="width: 60px;" />
								</colgroup>
                                <thead>
                                    <tr>
                                        <th> 车辆编码 </th>
                                        <th> 终点距离 </th>
                                        <th> 终点时间 </th>
                                        <th> 指令 </th>
                                        <th> 速度 </th>
                                        <th> 路牌 </th>
                                    </tr>
                                </thead>
                             </table>
                             <div class="table_wrap">
                             <table class="table table-striped table-bordered table-advance table-hover">
                             	<colgroup>
									<col style="width: 79px;" />
									<col style="width: 78px;" />
									<col style="width: 75px;" />
									<col style="width: 57px;" />
									<col style="width: 60px;" />
								</colgroup>
                                <tbody>
                                    <tr>
                                        <td> W9H108 </td>
                                        <td> 13.143 </td>
                                        <td> 82 </td>
                                        <td>
                                            <span class="label label-sm label-success"> 发送 </span>
                                        </td>
                                        <td> 16.00 </td>
                                        <td> 4 </td>
                                    </tr>
                                    <tr>
                                        <td> W9H108 </td>
                                        <td> 13.143 </td>
                                        <td> 82 </td>
                                        <td>
                                            <span class="label label-sm label-success"> 发送 </span>
                                        </td>
                                        <td> 16.00 </td>
                                        <td> 4 </td>
                                    </tr>
                                    <tr>
                                        <td> W9H108 </td>
                                        <td> 13.14 </td>
                                        <td> 82 </td>
                                        <td>
                                            <span class="label label-sm label-success"> 发送 </span>
                                        </td>
                                        <td> 16.00 </td>
                                        <td> 4 </td>
                                    </tr>
                                     <tr>
                                        <td> W9H108 </td>
                                        <td> 13.14 </td>
                                        <td> 82 </td>
                                        <td>
                                            <span class="label label-sm label-success"> 发送 </span>
                                        </td>
                                        <td> 16.00 </td>
                                        <td> 4 </td>
                                    </tr>
                                    <tr>
                                        <td> W9H108 </td>
                                        <td> 13.14 </td>
                                        <td> 82 </td>
                                        <td>
                                            <span class="label label-sm label-success"> 发送 </span>
                                        </td>
                                        <td> 16.00 </td>
                                        <td> 4 </td>
                                    </tr>
                                    <tr>
                                        <td> W9H108 </td>
                                        <td> 13.14 </td>
                                        <td> 82 </td>
                                        <td>
                                            <span class="label label-sm label-success"> 发送 </span>
                                        </td>
                                        <td> 16.00 </td>
                                        <td> 4 </td>
                                    </tr>
                                </tbody>
                            </table>
						</div>
					</div>
					<div class="col-lg-8 line_chart " >
						<div class="top">
							<div class="center">
								778路当日计划配车:9<br>
								在运营:9&nbsp;场内:0
							</div>
						</div>
					</div>
					<div class="col-lg-2 z-depth-2 down" >
					
						<div class="title" >
							发往南公交枢纽站方向 
							<span class="badge" > 7 </span>
							<span class="help_text">下行</span>
						</div>
                             <table class="table table-striped table-bordered table-advance">
							<colgroup>
								<col style="width: 79px;" />
								<col style="width: 78px;" />
								<col style="width: 75px;" />
								<col style="width: 57px;" />
								<col style="width: 60px;" />
							</colgroup>
							<thead>
                                  <tr>
                                     <th> 车辆编码 </th>
                                     <th> 终点距离 </th>
                                     <th> 终点时间 </th>
                                     <th> 指令 </th>
                                     <th> 速度 </th>
                                     <th> 路牌 </th>
                                 </tr>
                             </thead>
                             </table>
                             <div class="table_wrap">
                             <table class="table table-striped table-bordered table-advance table-hover">
	                            <colgroup>
									<col style="width: 79px;" />
									<col style="width: 78px;" />
									<col style="width: 75px;" />
									<col style="width: 57px;" />
									<col style="width: 60px;" />
								</colgroup>
                                <tbody>
                                    <tr>
                                        <td> W9H108 </td>
                                        <td> 13.143 </td>
                                        <td> 82 </td>
                                        <td>
                                            <span class="label label-sm label-success"> 发送 </span>
                                        </td>
                                        <td> 16.00 </td>
                                        <td> 4 </td>
                                    </tr>
                                    <tr>
                                        <td> W9H108 </td>
                                        <td> 13.143 </td>
                                        <td> 82 </td>
                                        <td>
                                            <span class="label label-sm label-success"> 发送 </span>
                                        </td>
                                        <td> 16.00 </td>
                                        <td> 4 </td>
                                    </tr>
                                    <tr>
                                        <td> W9H108 </td>
                                        <td> 13.143 </td>
                                        <td> 82 </td>
                                        <td>
                                            <span class="label label-sm label-success"> 发送 </span>
                                        </td>
                                        <td> 16.00 </td>
                                        <td> 4 </td>
                                    </tr>
                                     <tr>
                                        <td> W9H108 </td>
                                        <td> 13.14 </td>
                                        <td> 82 </td>
                                        <td>
                                            <span class="label label-sm label-success"> 发送 </span>
                                        </td>
                                        <td> 16.00 </td>
                                        <td> 4 </td>
                                    </tr>
                                    <tr>
                                        <td> W9H108 </td>
                                        <td> 13.14 </td>
                                        <td> 82 </td>
                                        <td>
                                            <span class="label label-sm label-success"> 发送 </span>
                                        </td>
                                        <td> 16.00 </td>
                                        <td> 4 </td>
                                    </tr>
                                </tbody>
                            </table>
					</div>
					</div>
				</div>
			</div>
			<div class="tab-pane fade" id="tab_map">
				地图
			</div>
			<div class="tab-pane fade" id="tab_85">
				85路
			</div>
			<div class="tab-pane fade" id="tab_50">
				浦东50路
			</div>
		</div>
	</div>
</div>

<script>
$(function() {
	// 关闭左侧栏
	if (!$('body').hasClass('page-sidebar-closed'))
		$('.menu-toggler.sidebar-toggler').click();
	
	
 	$('.card_wrap .table_wrap').slimscroll({
		height: '187px',
		alwaysVisible: true,
		opacity: .8
	}); 
 	
 setTimeout(function(){
	 /**
	 	type: 0 上行站点  1 下行站点  2  上下行共有  3  上下行共有(name不同)
	 */
	 var stations = 
		 [{name: '张江地铁站', type:'2', id: 1}
		, {name: '祖冲之路居里路aa', type:'1', id: 2}
		, {name: '祖冲之路高斯路', type:'1', id: 3}
		, {name: '祖冲之路张江路', type:'2', id: 4}
		, {name: '紫薇路张江路', type:'2', id: 5}
		, {name: '祖冲之路广兰路', type:'2', id: 6}
		, {name: '申江路祖冲之路', type:'2', id: 7}
		, {name: '申江路益丰路', type:'2', id: 8}
		, {name: ['盛夏路益江路', '科苑路孙环路'], type:'3', id: [9, 10]}
		, {name: '益江路盛夏路', type:'2', id: 11}
		, {name: '张东路益江路', type:'2', id: 12}
		, {name: '高科中路芳春路', type:'0', id: 13}
		, {name: '唐安路唐镇路', type:'2', id: 14}
		, {name: '唐安路唐兴路', type:'2', id: 15}
		, {name: '创新西路唐安路', type:'2', id: 16}
		, {name: '创新中路齐爱路', type:'2', id: 17}
		, {name: '齐爱路南漕路', type: '2', id: 18}
		, {name: '南漕路唐陆公路', type:'2', id: 19}
		, {name: '蛀虫之路广兰路', type:'2', id: 20}
		, {name: '上海火车站北广场', type:'2', id: 21}];

	
		//svg start-----------------
		//顶部距离
		var mTop = 21;
		//上下行之间高度
		var h = 132;

		var svg = d3.select('.line_chart').append('svg').attr('width',
				'100%');
		
		var upLine = d3.svg.line().x(function(d) {
			return d.cx;
		}).y(function(d) {
			return mTop;
		});

		var downLine = d3.svg.line().x(function(d) {
			return d.cx;
		}).y(function(d) {
			return mTop + h;
		});
		
		var circleClass = function(d, type, c){
			if(d.type == type){
				if(type == 1){
					c = 'up-circle-none';
				}
				else{
					c = 'down-circle-none';
				}
			}
			return c;
		}
		
		//横向比例尺  -根据svg的宽度平均分布站点
		var xScale = d3.scale.linear().domain([ 0, stations.length ])
				.range([ 50, $('.line_chart svg').width() + 5]);

		$.each(stations, function(i, d) {
			d.cx = xScale(i);
		});
			
		//上行线条
		svg.append('g').selectAll('path').data(stations.slice(0, stations.length - 1))
			.enter().append('path').attr('d', function(d, i) {
				return upLine([ d, stations[i + 1] ]);
			}).attr('class', 'up_path'); 

		//上行站点 外圆
		svg.append('g').selectAll('circle').data(stations).enter().append('circle')
				.attr('cy', mTop)
				.attr('class', function(d){return circleClass(d, 1, 'station_circle')})
				.attr('cx', function(d, i) {
					return d.cx;
				});
		
		//上行站点 内圆	
		svg.append('g').selectAll('circle').data(stations).enter().append('circle')
				.attr('class',  function(d){return circleClass(d, 1, 'up_station_circle_inside')})
				.attr('cy', mTop)
				.attr('id', function(d){
					var id = d.id;
					if(d.type == 3){
						id = d.id[0];
					}
					return id;
				})
				.attr('cx', function(d, i) {
					return d.cx;
				});
			
		//下行线条
		svg.append('g').selectAll('path')
				.data(stations.slice(0, stations.length - 1)).enter()
				.append('path').attr('d', function(d, i) {
					return downLine([ d, stations[i + 1] ]);
				}).attr('class', 'down_path'); 

		//下行站点 外圆
		svg.append('g').selectAll('circle').data(stations).enter().append('circle')
				.attr('class', function(d){return circleClass(d, 0, 'station_circle')})
				.attr('cy', mTop + h)
				.attr('cx', function(d, i) {
					return d.cx;
				});
		//下行站点 内圆
		svg.append('g').selectAll('circle').data(stations).enter().append('circle')
				.attr('class', function(d){return circleClass(d, 0, 'down_station_circle_inside')})
				.attr('cy', mTop + h)
				.attr('cx', function(d, i) {
					return d.cx;
				})
				.attr('id', function(d){
					var id = d.id;
					if(d.type == 3){
						id = d.id[1];
					}
					return id;
				});
		
		
		 var line = d3.svg.line().x(function(d) {
				return d.attr('cx');
			}).y(function(d) {
				return d.attr('cy');
			});
	 
	 	//左括号
 		svg.append('g').append('path')
 			.attr('d', function(){
 				var up = svg.select('.up_station_circle_inside')
					,down = svg.select('.down_station_circle_inside');
 				
 				var upX = parseInt(up.attr('cx')) -5
 					, upY =  parseInt(up.attr('cy')) + 8
 					, downX = parseInt(down.attr('cx')) -5
 					, downY = parseInt(down.attr('cy')) -8
 					,arc = (upX - 18);
 				return 'M' + upX + ',' + upY + ' C' + arc + ',' + (upY + 5) + ' ' + arc + ',' + (downY - 5) + ' ' + downX + ',' + downY;
 			})
 			.attr('class', 'up_path')
 			.attr('fill', 'none'); 
 		
	 	//右括号
 		svg.append('g').append('path')
			.attr('d', function(){
				var up = $('.up_station_circle_inside:last')
					,down = $('.down_station_circle_inside:last');
				
				var upX = parseInt(up.attr('cx')) +5
					, upY =  parseInt(up.attr('cy')) + 8
					, downX = parseInt(down.attr('cx')) +5
					, downY = parseInt(down.attr('cy')) -8
					,arc = (upX + 18);
				return 'M' + upX + ',' + upY + ' C' + arc + ',' + (upY + 5) + ' ' + arc + ',' + (downY - 5) + ' ' + downX + ',' + downY;
			})
			.attr('class', 'down_path')
			.attr('fill', 'none'); 
	 	
	 	
	 	
 		//文字
 		var getText = function(t){
			if (t.length > 7) {
				return t.substring(0, 7) + '·';
			}
			return t;
		}
		svg.append('g').selectAll('text').data(stations).enter()
			.append('text')
			.attr('y',
				function(d, i) {
					var t;
					if(d.type == 3){
						t = d.name[0];
					}
					else{
						t = d.name;
					}
					return mTop + 5 + (h - (18 * (t.length > 7 ? 7 : t.length))) / 2;
				})
			.attr('class', function(d, i){
				var classz = 'station_text';
				if(i == 0)
					classz += ' start';
				else if(i == stations.length - 1)
					classz += ' end';
				return classz;
			})
			.text(function(d){
				if(d.type == 3){
					$(this).attr('type', 3).attr('downName', d.name[1]);
					return getText(d.name[0]);
				}
				return getText(d.name);
			})
			.attr('x', function(d, i) {
				return xScale(i);
			});
		
		
		//上下行不同名修正
		var lastG = svg.append('g');
		$.each($('.station_text[type=3]'), function(i, obj){
			var x = parseInt($(obj).attr('x'))
				,diff = 8;
			
			lastG.append('text')
				.attr('y', $(obj).attr('y'))
				.attr('class', 'station_text')
				.attr('x', (x + diff))
				.attr('fill', 'red')
				.text($(obj).attr('downname'));
			
			$(obj).attr('fill', '#337AB7')
				.removeAttr('type').removeAttr('downname')
				.attr('x', x - diff);
		});
	}, 200);
	});
</script>