dashboard.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. define(['jquery', 'bootstrap', 'backend', 'addtabs', 'table', 'echarts', 'echarts-theme','form', 'template'], function ($, undefined, Backend, Datatable, Table, Echarts, undefined,Form, 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: [__('Register user')]
  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: __('Register user'),
  47. type: 'line',
  48. smooth: true,
  49. areaStyle: {
  50. normal: {}
  51. },
  52. lineStyle: {
  53. normal: {
  54. width: 1.5
  55. }
  56. },
  57. data: Config.userdata
  58. }]
  59. };
  60. // 使用刚指定的配置项和数据显示图表。
  61. myChart.setOption(option);
  62. $(window).resize(function () {
  63. myChart.resize();
  64. });
  65. $(document).on("click", ".btn-refresh", function () {
  66. setTimeout(function () {
  67. myChart.resize();
  68. }, 0);
  69. });
  70. },
  71. order: function () {
  72. // 基于准备好的dom,初始化echarts实例
  73. var myChart = Echarts.init(document.getElementById('echart'), 'walden');
  74. // 指定图表的配置项和数据
  75. var option = {
  76. title: {
  77. text: '订单统计'
  78. },
  79. tooltip: {
  80. trigger: 'axis'
  81. },
  82. legend: {
  83. data: ['笔数']
  84. },
  85. grid: {
  86. left: '3%',
  87. right: '4%',
  88. bottom: '3%',
  89. containLabel: true
  90. },
  91. toolbox: {
  92. feature: {
  93. saveAsImage: {}
  94. }
  95. },
  96. xAxis: {
  97. type: 'category',
  98. boundaryGap: false,
  99. data: Config.ec_date
  100. },
  101. yAxis: {
  102. type: 'value'
  103. },
  104. series: [
  105. {
  106. name: '笔数',
  107. type: 'line',
  108. // stack: 'Total',
  109. data: Config.ec_ordernum
  110. },
  111. ]
  112. };
  113. // 使用刚指定的配置项和数据显示图表。
  114. myChart.setOption(option);
  115. $(window).resize(function () {
  116. myChart.resize();
  117. });
  118. $(document).on("click", ".btn-refresh", function () {
  119. setTimeout(function () {
  120. myChart.resize();
  121. }, 0);
  122. });
  123. },
  124. api: {
  125. bindevent: function () {
  126. Form.api.bindevent($("form[role=form]"));
  127. }
  128. }
  129. };
  130. return Controller;
  131. });