tongji.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723
  1. $(function () {
  2. // var whdef = 100/1920;// 表示1920的设计图,使用100PX的默认值
  3. var whdef = 100/916;// 表示1920的设计图,使用100PX的默认值
  4. var wH = window.innerHeight;// 当前窗口的高度
  5. var wW = window.innerWidth;// 当前窗口的宽度
  6. // var rem = wW * whdef;// 以默认比例值乘以当前窗口宽度,得到该宽度下的相应FONT-SIZE值
  7. var rem = wH * whdef;// 以默认比例值乘以当前窗口宽度,得到该宽度下的相应FONT-SIZE值
  8. $('html').css('font-size', rem + "px");
  9. //加载统计图1---能耗饼图
  10. loadoOption1();
  11. //加载统计图2---能耗条形图
  12. loadoOption2();
  13. //加载统计图3----能耗折线图
  14. loadoOption3();
  15. //加载统计图4----6个月能耗
  16. loadoOption4();
  17. //loadOptionYibiao1();
  18. // loadOptionRiLi();
  19. }) ;
  20. function loadOptionBaojingbar(){
  21. }
  22. function getVirtulData() {
  23. var currDate = new Date();
  24. var currMonth = echarts.format.formatTime('yyyy-MM', currDate);
  25. var date = +echarts.number.parseDate(currMonth+"-01");
  26. var end = +echarts.number.parseDate(new Date());
  27. var dayTime = 3600 * 24 * 1000;
  28. var data = [];
  29. for (var time = date; time < end; time += dayTime) {
  30. data.push([
  31. echarts.format.formatTime('yyyy-MM-dd', time),
  32. Math.floor(Math.random() * 100)
  33. ]);
  34. }
  35. return data;
  36. }
  37. function getPieSeries(scatterData, chart) {
  38. return echarts.util.map(scatterData, function (item, index) {
  39. var center = chart.convertToPixel('calendar', item);
  40. return {
  41. id: index + 'pie',
  42. type: 'pie',
  43. center: center,
  44. label: {
  45. normal: {
  46. formatter: '{c}',
  47. position: 'inside'
  48. }
  49. },
  50. radius: 25 ,
  51. data: []
  52. };
  53. });
  54. }
  55. function getPieSeriesUpdate(scatterData, chart) {
  56. return echarts.util.map(scatterData, function (item, index) {
  57. var center = chart.convertToPixel('calendar', item);
  58. return {
  59. id: index + 'pie',
  60. type: 'pie',
  61. center: center,
  62. label: {
  63. normal: {
  64. formatter: '{c}',
  65. position: 'inside'
  66. }
  67. },
  68. radius: 25 ,
  69. data: [ ]
  70. };
  71. });
  72. }
  73. function loadOptionRiLi(){
  74. // var dom = document.getElementById("container");
  75. // var myChart = echarts.init(dom);
  76. var app = {};
  77. option = null;
  78. var cellSize = [120, 80];
  79. var pieRadius = 30;
  80. var scatterData = getVirtulData();
  81. if(myChartRiLi){
  82. myChartRiLi.clear();
  83. }
  84. option = {
  85. tooltip : {},
  86. legend: {
  87. data: [ {
  88. name: '正常',
  89. // 设置文本为红色
  90. textStyle: {
  91. color: 'white'
  92. }
  93. },{
  94. name: '报警',
  95. // 设置文本为红色
  96. textStyle: {
  97. color: 'white'
  98. }
  99. },{
  100. name: '设备离线',
  101. // 设置文本为红色
  102. textStyle: {
  103. color: 'white'
  104. }
  105. }],
  106. top: 1,
  107. color:'red'
  108. },
  109. calendar: {
  110. top: 45,
  111. left: 'center',
  112. height:'auto',
  113. orient: 'vertical',
  114. cellSize: cellSize,
  115. splitLine: {
  116. show: true,
  117. lineStyle: {
  118. color: 'rgb(0,136,212)',
  119. width: 1,
  120. type: 'solid'
  121. }
  122. },
  123. yearLabel: {
  124. show: false,
  125. textStyle: {
  126. fontSize: 30
  127. }
  128. },
  129. dayLabel: {
  130. margin: 7,
  131. firstDay: 1,
  132. nameMap: ['日', '一', '二', '三', '四', '五', '六'],
  133. color:'white',
  134. fontSize:13
  135. },
  136. monthLabel: {
  137. show: true
  138. },
  139. itemStyle: {
  140. normal: {
  141. color: 'rgba(255,255,255,0)',
  142. borderWidth: 1,
  143. borderColor: 'rgb(0,136,212)'
  144. }
  145. },
  146. range: ['2018-07']
  147. },
  148. series: [{
  149. id: 'label',
  150. type: 'scatter',
  151. coordinateSystem: 'calendar',
  152. symbolSize: 1,
  153. label: {
  154. normal: {
  155. show: true,
  156. formatter: function (params) {
  157. return echarts.format.formatTime('dd', params.value[0]);
  158. },
  159. offset: [-cellSize[0] / 2 + 10, -cellSize[1] / 2 + 10],
  160. textStyle: {
  161. color: 'white',
  162. fontSize: 14
  163. },
  164. }
  165. },
  166. data: scatterData
  167. }]
  168. };
  169. if (!app.inNode) {
  170. var pieInitialized;
  171. setTimeout(function () {
  172. pieInitialized = true;
  173. myChartRiLi.setOption({
  174. series: getPieSeriesUpdate(scatterData, myChartRiLi)
  175. });
  176. }, 10);
  177. app.onresize = function () {
  178. if (pieInitialized) {
  179. myChartRiLi.setOption({
  180. series: getPieSeriesUpdate(scatterData, myChartRiLi)
  181. });
  182. }
  183. };
  184. };
  185. if (option && typeof option === "object") {
  186. myChartRiLi.setOption(option, true);
  187. }
  188. }
  189. function loadOptionYibiao1(){
  190. option = {
  191. tooltip : {
  192. formatter: "{a} <br/>{b} : {c}%"
  193. },
  194. toolbox: {
  195. show : true,
  196. feature : {
  197. mark : {show: true},
  198. restore : {show: true},
  199. saveAsImage : {show: true}
  200. }
  201. },
  202. series : [
  203. {
  204. name:'业务指标',
  205. type:'gauge',
  206. startAngle: 180,
  207. endAngle: 0,
  208. center : ['50%', '90%'], // 默认全局居中
  209. radius : 320,
  210. axisLine: { // 坐标轴线
  211. lineStyle: { // 属性lineStyle控制线条样式
  212. width: 200
  213. }
  214. },
  215. axisTick: { // 坐标轴小标记
  216. splitNumber: 10, // 每份split细分多少段
  217. length :12, // 属性length控制线长
  218. },
  219. axisLabel: { // 坐标轴文本标签,详见axis.axisLabel
  220. formatter: function(v){
  221. switch (v+''){
  222. case '10': return '低';
  223. case '50': return '中';
  224. case '90': return '高';
  225. default: return '';
  226. }
  227. },
  228. textStyle: { // 其余属性默认使用全局文本样式,详见TEXTSTYLE
  229. color: '#fff',
  230. fontSize: 15,
  231. fontWeight: 'bolder'
  232. }
  233. },
  234. pointer: {
  235. width:50,
  236. length: '90%',
  237. color: 'rgba(255, 255, 255, 0.8)'
  238. },
  239. title : {
  240. show : true,
  241. offsetCenter: [0, '-60%'], // x, y,单位px
  242. textStyle: { // 其余属性默认使用全局文本样式,详见TEXTSTYLE
  243. color: '#fff',
  244. fontSize: 30
  245. }
  246. },
  247. detail : {
  248. show : true,
  249. backgroundColor: 'rgba(0,0,0,0)',
  250. borderWidth: 0,
  251. borderColor: '#ccc',
  252. width: 100,
  253. height: 40,
  254. offsetCenter: [0, -40], // x, y,单位px
  255. formatter:'{value}%',
  256. textStyle: { // 其余属性默认使用全局文本样式,详见TEXTSTYLE
  257. fontSize : 50
  258. }
  259. },
  260. data:[{value: 50, name: '完成率'}]
  261. }
  262. ]
  263. };
  264. //yibiao1.setOption(option);
  265. }
  266. //加载统计图1数据
  267. function loadoOption1(){
  268. myChart1.clear();
  269. var data = [{
  270. value:92,
  271. name: '室内灯'
  272. },{
  273. value:132,
  274. name: '室外灯'
  275. }, {
  276. value: 181,
  277. name: '水泵'
  278. }, {
  279. value: 142,
  280. name: '空调'
  281. }, {
  282. value: 212,
  283. name: '电梯'
  284. }, {
  285. value: 28,
  286. name: '周边设施'
  287. }, {
  288. value: 382,
  289. name: '音响'
  290. }, {
  291. value: 41,
  292. name: '网络设施'
  293. }];
  294. var option = {
  295. title: {
  296. text:'1000',
  297. subtext: '总功率',
  298. left:'center',
  299. top:'50%',
  300. padding:[24,0],
  301. textStyle:{
  302. color:'#fff',
  303. fontSize:18,
  304. align:'center'
  305. }
  306. },
  307. backgroundColor: 'rgba(255,255,255,0)',
  308. tooltip: {
  309. trigger: 'item',
  310. formatter: "{a} <br/>{b}: {c} ({d}%)",
  311. extraCssText:'height:60px;',
  312. position: function (point, params, dom, rect, size) {
  313. // 鼠标坐标和提示框位置的参考坐标系是:以外层div的左上角那一点为原点,x轴向右,y轴向下
  314. // 提示框位置
  315. var x = 0; // x坐标位置
  316. var y = 0; // y坐标位置
  317. // 当前鼠标位置
  318. var pointX = point[0];
  319. var pointY = point[1];
  320. // 外层div大小
  321. // var viewWidth = size.viewSize[0];
  322. // var viewHeight = size.viewSize[1];
  323. // 提示框大小
  324. var boxWidth = size.contentSize[0];
  325. var boxHeight = size.contentSize[1];
  326. // boxWidth > pointX 说明鼠标左边放不下提示框
  327. if (boxWidth > pointX) {
  328. x = 5;
  329. } else { // 左边放的下
  330. x = pointX - boxWidth;
  331. }
  332. // boxHeight > pointY 说明鼠标上边放不下提示框
  333. if (boxHeight > pointY) {
  334. y = 5;
  335. } else { // 上边放得下
  336. y = pointY - boxHeight;
  337. }
  338. return [x, y];
  339. }
  340. },
  341. legend: {
  342. orient: 'horizontal',
  343. top: '2%',
  344. left: 'center',
  345. data: ['室内灯','室外灯','空调','水泵','电梯','周边设施','音响','网络设施'],
  346. textStyle:{
  347. fontSize: 11,
  348. color: '#6cbbe6'
  349. }
  350. },
  351. series: [{
  352. name: '受理数',
  353. type: 'pie',
  354. selectedMode: 'single',
  355. center : ['50%', '60%'],
  356. radius: ['40%', '58%'],
  357. color: ['#C1232B','#B5C334','#FCCE10','#E87C25','#27727B','#FE8463','#9BCA63','#FAD860','#F3A43B','#60C0DD'],
  358. label: {
  359. normal: {
  360. show: false,
  361. position: 'outside',
  362. formatter: '{b}',
  363. textStyle: {
  364. color: '#3db3cb',
  365. fontSize: 12
  366. }
  367. }
  368. },
  369. labelLine: {
  370. normal: {
  371. show: false,
  372. lineStyle: {
  373. color: '#3db3cb'
  374. }
  375. }
  376. },
  377. animationDuration: function (idx) {
  378. // 越往后的数据延迟越大
  379. return 10000;
  380. },
  381. data: data
  382. }]
  383. };
  384. myChart1.setOption(option);
  385. }
  386. //加载统计图2数据
  387. function loadoOption2(){
  388. myChart2.clear();
  389. var option = {
  390. tooltip: {
  391. trigger: 'axis',
  392. axisPointer: {
  393. type: 'shadow'
  394. }
  395. },
  396. grid: {
  397. top:'5%',
  398. left: '5%',
  399. right: '5%',
  400. bottom: '5%',
  401. containLabel: true,
  402. },
  403. xAxis: {
  404. type: 'value',
  405. splitLine: {show: false},
  406. boundaryGap: [0, 0.01],
  407. axisLabel:{
  408. textStyle:{
  409. color: '#6cbbe6'
  410. }
  411. },
  412. },
  413. yAxis: {
  414. type: 'category',
  415. splitLine: {show: false},
  416. data: ['室内灯','室外灯','空调','水泵','电梯','周边设施','音响','网络设施'],
  417. axisLabel:{
  418. textStyle:{
  419. fontSize: 15,
  420. color: '#6cbbe6'
  421. }
  422. },
  423. },
  424. series: [
  425. {
  426. name: '办理数',
  427. itemStyle: {
  428. normal: {
  429. color: function(params) {
  430. // build a color map as your need.
  431. var colorList = [
  432. '#C1232B','#B5C334','#FCCE10','#E87C25','#27727B',
  433. '#FE8463','#9BCA63','#FAD860','#F3A43B','#60C0DD',
  434. '#D7504B','#C6E579','#F4E001','#F0805A','#26C0C0'
  435. ];
  436. return colorList[params.dataIndex]
  437. },
  438. shadowBlur:100,
  439. shadowColor: 'rgba(0, 0, 0, 0.5)',
  440. label : {
  441. show : false //隐藏标示文字
  442. },
  443. labelLine : {
  444. show : false //隐藏标示线
  445. }
  446. }
  447. },
  448. barWidth:20,
  449. barGap:40,
  450. type: 'bar',
  451. data: [92,132,142,181,212,28,382,41]
  452. }
  453. ]
  454. };
  455. myChart2.setOption(option);
  456. }
  457. //加载统计图3数据
  458. function loadoOption3(){
  459. myChart3.clear();
  460. var option = {
  461. title: {
  462. text: '最近6个月能耗统计',
  463. show: true,
  464. textStyle: {
  465. fontWeight: 'normal',
  466. fontSize: 22,
  467. color: '#3db3cb'
  468. },
  469. left: '2%',
  470. top: '2%'
  471. },
  472. tooltip: {
  473. trigger: 'axis',
  474. axisPointer: {
  475. lineStyle: {
  476. color: '#3db3cb'
  477. }
  478. }
  479. },
  480. grid: {
  481. left: '3%',
  482. right: '4%',
  483. bottom: '3%',
  484. containLabel: true
  485. },
  486. xAxis: [{
  487. type: 'category',
  488. boundaryGap: false,
  489. axisLine: {
  490. lineStyle: {
  491. color: 'rgba(128, 128, 128, 0.5)'
  492. }
  493. },
  494. axisLabel: {
  495. margin: 10,
  496. textStyle: {
  497. fontSize: 14,
  498. color: '#999'
  499. }
  500. },
  501. data: ['2017-07', '2017-08', '2017-09', '2017-10', '2017-11', '2017-12']
  502. }],
  503. yAxis: [{
  504. type: 'value',
  505. name: '',
  506. axisTick: {
  507. show: false
  508. },
  509. axisLine: {
  510. show:false,
  511. lineStyle: {
  512. color: '#fff'
  513. }
  514. },
  515. axisLabel: {
  516. margin: 10,
  517. textStyle: {
  518. fontSize: 14,
  519. color: '#799dff'
  520. }
  521. },
  522. splitLine: {
  523. lineStyle: {
  524. type: 'dashed',
  525. color: 'rgba(121, 157, 255, 0.5)'
  526. }
  527. }
  528. }],
  529. series: [{
  530. name: '能耗统计',
  531. type: 'line',
  532. smooth: true,
  533. symbol: 'circle',
  534. symbolSize: 5,
  535. showSymbol: false,
  536. lineStyle: {
  537. normal: {
  538. width: 1
  539. }
  540. },
  541. areaStyle: {
  542. normal: {
  543. color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  544. offset: 0,
  545. color: 'rgba(0, 136, 212, 0.2)'
  546. }, {
  547. offset: 1,
  548. color: 'rgba(0, 136, 212, 0)'
  549. }], false),
  550. shadowColor: 'rgba(0, 0, 0, 0.1)',
  551. shadowBlur: 10
  552. }
  553. },
  554. itemStyle: {
  555. normal: {
  556. color: 'rgb(0,136,212)',
  557. borderColor: 'rgba(0,136,212,0.2)',
  558. borderWidth: 12
  559. }
  560. },
  561. data: [120, 110, 145, 122, 165, 150]
  562. }, ]
  563. }
  564. myChart3.setOption(option);
  565. }
  566. //热门事项排行
  567. function loadoOption4(){
  568. myChart4.clear();
  569. // var option = {
  570. // tooltip: {
  571. // trigger: 'axis',
  572. // axisPointer: {
  573. // type: 'shadow'
  574. // }
  575. // },
  576. // grid: {
  577. // top:'5%',
  578. // left: '5%',
  579. // right: '5%',
  580. // bottom: '5%',
  581. // containLabel: true,
  582. // },
  583. // yAxis: {
  584. // type: 'value',
  585. //
  586. // splitLine: {show: false},
  587. // boundaryGap: [0, 0.01],
  588. // axisLabel:{
  589. // textStyle:{
  590. // color: '#6cbbe6'
  591. // }
  592. // },
  593. // },
  594. // xAxis: {
  595. // type: 'category',
  596. // splitLine: {show: false},
  597. // data: ['价格','护士','再生育证审批','社会团体登记','医师执业注册','印刷企业设立','污染物排放','教师资格认定'],
  598. // axisLabel:{
  599. // textStyle:{
  600. // fontSize: 10,
  601. // color: '#6cbbe6'
  602. // }
  603. // },
  604. // },
  605. // series: [
  606. // {
  607. // name: '办理数',
  608. // itemStyle: {
  609. // normal: {
  610. // color: function(params) {
  611. // // build a color map as your need.
  612. // var colorList = [
  613. // '#C1232B','#B5C334','#FCCE10','#E87C25','#27727B',
  614. // '#FE8463','#9BCA63','#FAD860','#F3A43B','#60C0DD',
  615. // '#D7504B','#C6E579','#F4E001','#F0805A','#26C0C0'
  616. // ];
  617. // return colorList[params.dataIndex]
  618. // },
  619. // shadowBlur:100,
  620. // shadowColor: 'rgba(0, 0, 0, 0.5)'
  621. // }
  622. // },
  623. // barWidth:10,
  624. // barGap:40,
  625. // type: 'bar',
  626. // data: [92,132,142,181,212,28,382,41]
  627. // }
  628. // ]
  629. // };
  630. option = {
  631. tooltip : {
  632. trigger: 'axis'
  633. },
  634. calculable : true,
  635. xAxis : [
  636. {
  637. type : 'category',
  638. data : ['集水井','变压器','备变压器','消防泵','水泵'],
  639. axisLabel:{
  640. textStyle:{
  641. color: '#6cbbe6'
  642. }
  643. }
  644. }
  645. ],
  646. yAxis : [
  647. {
  648. type : 'value',
  649. axisLabel:{
  650. textStyle:{
  651. color: '#6cbbe6'
  652. }
  653. }
  654. }
  655. ],
  656. series : [
  657. {
  658. name:'报警统计',
  659. type:'bar',
  660. data:[2, 4, 7, 23, 9],
  661. itemStyle: {
  662. normal: {
  663. color: function(params) {
  664. // build a color map as your need.
  665. var colorList = [
  666. '#C1232B','#B5C334','#FCCE10','#E87C25','#27727B'
  667. ];
  668. return colorList[params.dataIndex]
  669. },
  670. shadowBlur:100,
  671. shadowColor: 'rgba(0, 0, 0, 0.5)'
  672. }
  673. },
  674. barWidth:80,
  675. barGap:40,
  676. markPoint : {
  677. data : [
  678. {type : 'max', name: '最大值'},
  679. {type : 'min', name: '最小值'}
  680. ]
  681. },
  682. markLine : {
  683. data : [
  684. {type : 'average', name: '平均值'}
  685. ]
  686. }
  687. }
  688. ]
  689. };
  690. myChart4.setOption(option);
  691. }