dashboard.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. $.ajax({
  5. type : "post",
  6. async : false,
  7. url : "Dashboard/ecDashboard",
  8. data : {},
  9. dataType : "json",
  10. success : function(result) {
  11. console.log(result);
  12. var myChart = Echarts.init(document.getElementById('echart'), 'walden');
  13. var option = {
  14. title: {
  15. text: ''
  16. },
  17. // color: ['#003366', '#006699', '#4cabce'],
  18. tooltip: {
  19. trigger: 'axis',
  20. // axisPointer: {
  21. // type: 'shadow'
  22. // }
  23. },
  24. // toolbox: {//图片下载
  25. // feature: {
  26. // saveAsImage: {}
  27. // }
  28. // },
  29. grid: {//图表大小
  30. left: '2%',
  31. right: '5%',
  32. bottom: '3%',
  33. containLabel: true
  34. },
  35. xAxis: [
  36. {
  37. type: 'category',
  38. boundaryGap: false,
  39. data: Config.column//日期
  40. }
  41. ],
  42. yAxis: [
  43. {
  44. type: 'value'
  45. }
  46. ],
  47. series: [
  48. {
  49. name: '订单',
  50. type: 'line',
  51. stack: 'Total',
  52. // label: {//显示数据文字
  53. // show: true,
  54. // position: 'top'
  55. // },
  56. areaStyle: {},
  57. emphasis: {
  58. focus: 'series'
  59. },
  60. // data: [1,1,10,30,35,0,result]
  61. data: result
  62. },
  63. ]
  64. };
  65. // 使用刚指定的配置项和数据显示图表。
  66. myChart.setOption(option);
  67. $(window).resize(function () {
  68. myChart.resize();
  69. });
  70. $(document).on("click", ".btn-refresh", function () {
  71. setTimeout(function () {
  72. myChart.resize();
  73. }, 0);
  74. });
  75. }
  76. });
  77. }
  78. };
  79. return Controller;
  80. });