11@extends (' admin.layouts' )
22
33@section (' css' )
4- <link href =" /assets/global/plugins/datatables/datatables.min.css" rel =" stylesheet" type =" text/css" />
5- <link href =" /assets/global/plugins/datatables/plugins/bootstrap/datatables.bootstrap.css" rel =" stylesheet" type =" text/css" />
64@endsection
5+
76@section (' title' , ' 控制面板' )
87@section (' content' )
98 <!-- BEGIN CONTENT BODY -->
2221 <!-- BEGIN PAGE BASE CONTENT -->
2322 <div class =" row" >
2423 <div class =" col-md-12" >
25- <!-- BEGIN PORTLET-->
26- <div class =" portlet light bordered" >
24+ <div class =" portlet light portlet-fit bordered" >
25+ <div class =" portlet-title" >
26+ <div class =" caption" >
27+ <i class =" icon-settings font-dark" ></i >
28+ <span class =" caption-subject font-dark sbold uppercase" >节点流量(近30天)</span >
29+ </div >
30+ </div >
2731 <div class =" portlet-body" >
28- 、、、
32+ < div id = " chart " class = " chart " > </ div >
2933 </div >
3034 </div >
31- <!-- END PORTLET-->
3235 </div >
3336 </div >
3437 <!-- END PAGE BASE CONTENT -->
3538 </div >
3639 <!-- END CONTENT BODY -->
3740@endsection
3841@section (' script' )
39- <script src =" /assets/global/plugins/jquery-qrcode /jquery.qrcode .min.js" type =" text/javascript" ></script >
42+ <script src =" /assets/global/plugins/flot /jquery.flot .min.js" type =" text/javascript" ></script >
4043 <script src =" /assets/global/plugins/jquery-ui/jquery-ui.min.js" type =" text/javascript" ></script >
4144 <script src =" /assets/global/plugins/bootbox/bootbox.min.js" type =" text/javascript" ></script >
4245
4346 <script type =" text/javascript" >
44- //
47+ var ChartsFlotcharts = function () {
48+ return {
49+ init : function () {
50+ App .addResizeHandler (function () {
51+ Charts .initPieCharts ();
52+ });
53+ },
54+
55+ initCharts : function () {
56+ if (! jQuery .plot ) {
57+ return ;
58+ }
59+
60+ function chart () {
61+ if ($ (' #chart' ).size () != 1 ) {
62+ return ;
63+ }
64+
65+ @if (! empty ($traffic ) )
66+ @foreach ($traffic as $node_id => $node_traffic_list )
67+ {{ ' var node_' . $node_id } } = [
68+ @foreach ($node_traffic_list as $key => $vo )
69+ [{{ $key + 1 } } , {{ $vo -> total } } ],
70+ @endforeach
71+ ];
72+
73+ @endforeach
74+ @endif
75+
76+ var plot = $ .plot ($ (" #chart" ), [
77+ @if (! empty ($traffic ) )
78+ @foreach ($traffic as $node_id => $node_traffic_list )
79+ {data: {{ ' node_' . $node_id } } , label: " 节点{{ $node_id } }" , lines: {lineWidth: 1 }, shadowSize: 0 },
80+ @endforeach
81+ @endif
82+ ], {
83+ series: {
84+ lines: {
85+ show: true ,
86+ lineWidth: 2 ,
87+ fill: true ,
88+ fillColor: {
89+ colors: [{
90+ opacity: 0.05
91+ }, {
92+ opacity: 0.01
93+ }]
94+ }
95+ },
96+ points: {
97+ show: true ,
98+ radius: 3 ,
99+ lineWidth: 1
100+ },
101+ shadowSize: 2
102+ },
103+ grid: {
104+ hoverable: true ,
105+ clickable: true ,
106+ tickColor: " #eee" ,
107+ borderColor: " #eee" ,
108+ borderWidth: 1
109+ },
110+ colors: [" #d12610" , " #37b7f3" , " #52e136" ],
111+ xaxis: {
112+ ticks: 11 ,
113+ tickDecimals: 0 ,
114+ tickColor: " #eee" ,
115+ },
116+ yaxis: {
117+ ticks: 11 ,
118+ tickDecimals: 0 ,
119+ tickColor: " #eee" ,
120+ }
121+ });
122+
123+
124+ function showTooltip (x , y , contents ) {
125+ $ (' <div id="tooltip">' + contents + ' </div>' ).css ({
126+ position: ' absolute' ,
127+ display: ' none' ,
128+ top: y + 5 ,
129+ left: x + 15 ,
130+ border: ' 1px solid #333' ,
131+ padding: ' 4px' ,
132+ color: ' #fff' ,
133+ ' border-radius' : ' 3px' ,
134+ ' background-color' : ' #333' ,
135+ opacity: 0.80
136+ }).appendTo (" body" ).fadeIn (200 );
137+ }
138+
139+ var previousPoint = null ;
140+ $ (" #chart" ).bind (" plothover" , function (event , pos , item ) {
141+ $ (" #x" ).text (pos .x .toFixed (2 ));
142+ $ (" #y" ).text (pos .y .toFixed (2 ));
143+
144+ if (item) {
145+ if (previousPoint != item .dataIndex ) {
146+ previousPoint = item .dataIndex ;
147+
148+ $ (" #tooltip" ).remove ();
149+ var x = item .datapoint [0 ].toFixed (2 ),
150+ y = item .datapoint [1 ].toFixed (2 );
151+
152+ showTooltip (item .pageX , item .pageY , item .series .label + " : " + y + ' M' );
153+ }
154+ } else {
155+ $ (" #tooltip" ).remove ();
156+ previousPoint = null ;
157+ }
158+ });
159+ }
160+
161+ chart ();
162+ }
163+ };
164+ }();
165+
166+ jQuery (document ).ready (function () {
167+ ChartsFlotcharts .init ();
168+ ChartsFlotcharts .initCharts ();
169+ });
45170 </script >
46171@endsection
0 commit comments