tongji.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. (function () {
  2. var page = {
  3. init: function ($page) {
  4. //扇形图数据
  5. chartMap = {};
  6. chartMap['chart-bingtu'] = echarts.init(document.getElementById('chart-bingtu'));
  7. var data = [{"name":"测试11","value":"9000.00"},{"name":"测试22","value":"100900.00"},{"name":"测试33","value":"0.00"}];
  8. var data2 = [{"name":"9000.00","value":"9000.00"},{"name":"100900.00","value":"100900.00"},{"name":"0.00","value":"0.00"}];
  9. //renlian.httpget("", { type: 'chart', id: _item.F_Id }, function(data) {
  10. //var type = $('#' + data.Id).attr('data-desktop');
  11. var legendData = [];
  12. $.each(data, function (_index, _item) {
  13. legendData.push(_item.name + _item.value);
  14. var data3 = {};
  15. data3.name = _item.name + _item.value;
  16. data3.value = _item.value;
  17. data2.push(data3);
  18. });
  19. console.log(data2);
  20. console.log(legendData);
  21. var xData = [];
  22. for(let i = 0;i < 5; ++i){
  23. var time = new Date(new Date() - 24*60*60*1000*i);
  24. var date = time.Format("yy-MM-dd");
  25. xData.push(date);
  26. }
  27. // var option = {};
  28. // option.tooltip = {
  29. // trigger: 'item',
  30. // formatter: "{a} <br/>{b}: {c} ({d}%)"
  31. // };
  32. // option.legend = {
  33. // orient: 'vertical',
  34. // left: 'right',
  35. // data: legendData
  36. // };
  37. // option.series = [{
  38. // name: '占比',
  39. // type: 'pie',
  40. // radius : '55%',
  41. // center: ['40%', '60%'],
  42. // itemStyle: {
  43. // emphasis: {
  44. // shadowBlur: 10,
  45. // shadowOffsetX: 0,
  46. // shadowColor: 'rgba(0, 0, 0, 0.5)'
  47. // }
  48. // },
  49. // data: data2
  50. // }];
  51. var option1 = {
  52. title:{
  53. text: '近期行驶里程',
  54. x:'center',
  55. },
  56. color: ['#3398DB'],
  57. tooltip : {
  58. trigger: 'axis',
  59. axisPointer : { // 坐标轴指示器,坐标轴触发有效
  60. type : 'shadow' // 默认为直线,可选为:'line' | 'shadow'
  61. }
  62. },
  63. grid: {
  64. left: '3%',
  65. right: '4%',
  66. bottom: '3%',
  67. containLabel: true
  68. },
  69. xAxis : [
  70. {
  71. type : 'category',
  72. data : xData,
  73. axisTick: {
  74. alignWithLabel: true
  75. },
  76. }
  77. ],
  78. yAxis : [
  79. {
  80. name: '里程/公里',
  81. type : 'value'
  82. }
  83. ],
  84. series : [
  85. {
  86. name:'行驶里程',
  87. type:'bar',
  88. barWidth: '50%',
  89. data:[10, 52, 50, 34, 40, 30, 20]
  90. }
  91. ]
  92. };
  93. //option.color = ['#df4d4b', '#304552', '#52bbc8', 'rgb(224,134,105)', '#8dd5b4', '#5eb57d', '#d78d2f'];
  94. chartMap['chart-bingtu'].setOption(option1);
  95. //列表数据
  96. //renlian.httpget(config.webapi + "renlian/adms/desktop/data", { type: 'Target', id: _item.F_Id }, function(data){});
  97. var drivingdata = '[{"name":"里程总计","value":"236.00km"},{"name":"累计时长","value":"0天24时00分"},{"name":"平均速度", "value":"9.83km/h"}]';
  98. data = JSON.parse(drivingdata);
  99. var _itemHtml = ''
  100. $.each(data, function (_index, _item) {
  101. if(_index == 2){
  102. _itemHtml += '\
  103. <div style="flex: 0 0 100%;height:120px;padding-top: 40px;" class="targetItem">\
  104. <div class="number">'+ _item.value + '</div>\
  105. <div class="name">'+ _item.name +'</div>\
  106. </div>';
  107. }else{
  108. _itemHtml += '\
  109. <div style="flex: 0 0 50%;height:120px;padding-top: 40px;" class="targetItem">\
  110. <div class="number">'+ _item.value + '</div>\
  111. <div class="name">'+ _item.name +'</div>\
  112. </div>';
  113. }
  114. $page.find('#driving-data').html(_itemHtml);
  115. });
  116. }
  117. };
  118. return page;
  119. })();