dashboard.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template', 'echarts', 'echarts-theme'], function ($, undefined, Backend, Table, Form, Template, Echarts) {
  2. var Controller = {
  3. index: function () {
  4. // 巡检次数
  5. var inspectionLine = Echarts.init(document.getElementById('line-inspection'), 'walden');
  6. var inspectionOption = {
  7. xAxis: {
  8. type: 'category',
  9. splitLine: {
  10. show: false
  11. },
  12. data: Config.statisticChart.weekDate
  13. },
  14. yAxis: {
  15. type: 'value'
  16. },
  17. series: [{
  18. data: Config.statisticChart.inspectionWeekData,
  19. type: 'line'
  20. }]
  21. };
  22. inspectionLine.setOption(inspectionOption);
  23. // 保养次数
  24. var maintenanceLine = Echarts.init(document.getElementById('line-maintenance'), 'walden');
  25. var maintenanceOption = {
  26. xAxis: {
  27. type: 'category',
  28. splitLine: {
  29. show: false
  30. },
  31. data: Config.statisticChart.weekDate
  32. },
  33. yAxis: {
  34. type: 'value'
  35. },
  36. series: [{
  37. data: Config.statisticChart.maintenanceWeekData,
  38. type: 'line'
  39. }]
  40. };
  41. maintenanceLine.setOption(maintenanceOption);
  42. // 维修工单数
  43. var repairLine = Echarts.init(document.getElementById('line-repair'), 'walden');
  44. var repairOption = {
  45. xAxis: {
  46. type: 'category',
  47. splitLine: {
  48. show: false
  49. },
  50. data: Config.statisticChart.weekDate
  51. },
  52. yAxis: {
  53. type: 'value',
  54. },
  55. series: [{
  56. data: Config.statisticChart.repairWeekData,
  57. type: 'bar',
  58. }]
  59. };
  60. repairLine.setOption(repairOption);
  61. var pieChart = Echarts.init(document.getElementById('pie-chart'), 'walden');
  62. var option = {
  63. tooltip: {
  64. trigger: 'item',
  65. formatter: '{a} <br/>{b}: {c} ({d}%)'
  66. },
  67. legend: {
  68. orient: 'vertical',
  69. left: 10,
  70. data: Config.statisticChart.failureCauseNames
  71. },
  72. series: [
  73. {
  74. name: '故障原因',
  75. type: 'pie',
  76. radius: ['50%', '70%'],
  77. avoidLabelOverlap: false,
  78. label: {
  79. normal: {
  80. show: false,
  81. position: 'center'
  82. },
  83. emphasis: {
  84. show: true,
  85. textStyle: {
  86. fontSize: '30',
  87. fontWeight: 'bold'
  88. }
  89. }
  90. },
  91. labelLine: {
  92. normal: {
  93. show: false
  94. }
  95. },
  96. data: Config.statisticChart.failureCause
  97. }
  98. ]
  99. };
  100. // 使用刚指定的配置项和数据显示图表。
  101. pieChart.setOption(option);
  102. }
  103. };
  104. return Controller;
  105. });