dashboard.js 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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. //饼图
  77. var barChart = Echarts.init(document.getElementById('bar-chart'), 'walden');
  78. option = {
  79. legend: {},
  80. tooltip: {},
  81. dataset: {
  82. source: [
  83. ['产品销售', '2015', '2016', '2017'],
  84. ['风扇', 43.3, 85.8, 93.7],
  85. ['电视机', 83.1, 73.4, 55.1],
  86. ['空调', 86.4, 65.2, 82.5],
  87. ['冰箱', 72.4, 53.9, 39.1]
  88. ]
  89. },
  90. xAxis: {type: 'category'},
  91. yAxis: {},
  92. // Declare several bar series, each will be mapped
  93. // to a column of dataset.source by default.
  94. series: [
  95. {type: 'bar'},
  96. {type: 'bar'},
  97. {type: 'bar'}
  98. ]
  99. };
  100. // 使用刚指定的配置项和数据显示图表。
  101. barChart.setOption(option);
  102. //饼图
  103. var pieChart = Echarts.init(document.getElementById('pie-chart'), 'walden');
  104. var option = {
  105. tooltip: {
  106. trigger: 'item',
  107. formatter: '{a} <br/>{b}: {c} ({d}%)'
  108. },
  109. legend: {
  110. orient: 'vertical',
  111. left: 10,
  112. data: Config.piecolumn,
  113. },
  114. series: [
  115. {
  116. name: '码流通统计',
  117. type: 'pie',
  118. radius: ['50%', '70%'],
  119. avoidLabelOverlap: false,
  120. label: {
  121. normal: {
  122. show: false,
  123. position: 'center'
  124. },
  125. emphasis: {
  126. show: true,
  127. textStyle: {
  128. fontSize: '30',
  129. fontWeight: 'bold'
  130. }
  131. }
  132. },
  133. labelLine: {
  134. normal: {
  135. show: false
  136. }
  137. },
  138. data: Config.piedata,
  139. }
  140. ]
  141. };
  142. // 使用刚指定的配置项和数据显示图表。
  143. pieChart.setOption(option);
  144. $(window).resize(function () {
  145. myChart.resize();
  146. });
  147. $(document).on("click", ".btn-refresh", function () {
  148. setTimeout(function () {
  149. myChart.resize();
  150. }, 0);
  151. });
  152. }
  153. };
  154. return Controller;
  155. });