dashboard.js 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. define(['jquery', 'bootstrap', 'backend', 'addtabs', 'table', 'echarts', 'echarts-theme', 'template'], function ($, undefined, Backend, Datatable, Table, Echarts, undefined, Template) {
  2. var Controller = {
  3. index: function () {
  4. // 基于准备好的dom,初始化echarts实例
  5. var myChart = Echarts.init(document.getElementById('echart'), 'walden');
  6. // 指定图表的配置项和数据
  7. var option = {
  8. title: {
  9. text: '',
  10. subtext: ''
  11. },
  12. color: [
  13. "#18d1b1",
  14. "#3fb1e3",
  15. "#626c91",
  16. "#a0a7e6",
  17. "#c4ebad",
  18. "#96dee8"
  19. ],
  20. tooltip: {
  21. trigger: 'axis'
  22. },
  23. legend: {
  24. data: ['溯源码','订单']
  25. },
  26. toolbox: {
  27. show: false,
  28. feature: {
  29. magicType: {show: true, type: ['stack', 'tiled']},
  30. saveAsImage: {show: true}
  31. }
  32. },
  33. xAxis: {
  34. type: 'category',
  35. boundaryGap: false,
  36. data: Config.column
  37. },
  38. yAxis: {},
  39. grid: [{
  40. left: 'left',
  41. top: 'top',
  42. right: '10',
  43. bottom: 30
  44. }],
  45. series: [{
  46. name: '溯源码',
  47. type: 'line',
  48. smooth: true,
  49. areaStyle: {
  50. normal: {}
  51. },
  52. lineStyle: {
  53. normal: {
  54. width: 1.5
  55. }
  56. },
  57. data: Config.codelistdata
  58. },
  59. {
  60. name: '订单',
  61. type: 'line',
  62. smooth: true,
  63. areaStyle: {
  64. normal: {}
  65. },
  66. lineStyle: {
  67. normal: {
  68. width: 1.5
  69. }
  70. },
  71. data: Config.orderlistdata
  72. }]
  73. };
  74. // 使用刚指定的配置项和数据显示图表。
  75. myChart.setOption(option);
  76. //饼图 7
  77. var pieChart = Echarts.init(document.getElementById('pie-chart-7'), 'walden');
  78. var option = {
  79. tooltip: {
  80. trigger: 'item',
  81. formatter: '{a} <br/>{b}: {c} ({d}%)'
  82. },
  83. legend: {
  84. orient: 'vertical',
  85. left: 10,
  86. data: Config.piecolumn,
  87. },
  88. series: [
  89. {
  90. name: '码流通统计',
  91. type: 'pie',
  92. radius: ['50%', '70%'],
  93. avoidLabelOverlap: false,
  94. label: {
  95. normal: {
  96. show: false,
  97. position: 'center'
  98. },
  99. emphasis: {
  100. show: true,
  101. textStyle: {
  102. fontSize: '30',
  103. fontWeight: 'bold'
  104. }
  105. }
  106. },
  107. labelLine: {
  108. normal: {
  109. show: false
  110. }
  111. },
  112. data: Config.piedata,
  113. }
  114. ]
  115. };
  116. // 使用刚指定的配置项和数据显示图表。
  117. pieChart.setOption(option);
  118. //饼图 30
  119. var pieChart = Echarts.init(document.getElementById('pie-chart-30'), 'walden');
  120. var option = {
  121. tooltip: {
  122. trigger: 'item',
  123. formatter: '{a} <br/>{b}: {c} ({d}%)'
  124. },
  125. legend: {
  126. orient: 'vertical',
  127. left: 10,
  128. data: Config.piecolumn30,
  129. },
  130. series: [
  131. {
  132. name: '码流通统计',
  133. type: 'pie',
  134. radius: ['50%', '70%'],
  135. avoidLabelOverlap: false,
  136. label: {
  137. normal: {
  138. show: false,
  139. position: 'center'
  140. },
  141. emphasis: {
  142. show: true,
  143. textStyle: {
  144. fontSize: '30',
  145. fontWeight: 'bold'
  146. }
  147. }
  148. },
  149. labelLine: {
  150. normal: {
  151. show: false
  152. }
  153. },
  154. data: Config.piedata30,
  155. }
  156. ]
  157. };
  158. // 使用刚指定的配置项和数据显示图表。
  159. pieChart.setOption(option);
  160. $(window).resize(function () {
  161. myChart.resize();
  162. });
  163. $(document).on("click", ".btn-refresh", function () {
  164. setTimeout(function () {
  165. myChart.resize();
  166. }, 0);
  167. });
  168. }
  169. };
  170. return Controller;
  171. });