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. 0
  13. var myChart = Echarts.init(document.getElementById('echart'), 'walden');
  14. var option = {
  15. title: {
  16. text: ''
  17. },
  18. // color: ['#003366', '#006699', '#4cabce'],
  19. tooltip: {
  20. trigger: 'axis',
  21. // axisPointer: {
  22. // type: 'shadow'
  23. // }
  24. },
  25. // toolbox: {//图片下载
  26. // feature: {
  27. // saveAsImage: {}
  28. // }
  29. // },
  30. grid: {//图表大小
  31. left: '2%',
  32. right: '5%',
  33. bottom: '3%',
  34. containLabel: true
  35. },
  36. xAxis: [
  37. {
  38. type: 'category',
  39. boundaryGap: false,
  40. data: Config.column//日期
  41. }
  42. ],
  43. yAxis: [
  44. {
  45. type: 'value'
  46. }
  47. ],
  48. series: [
  49. {
  50. name: '订单',
  51. type: 'line',
  52. stack: 'Total',
  53. // label: {//显示数据文字
  54. // show: true,
  55. // position: 'top'
  56. // },
  57. areaStyle: {},
  58. emphasis: {
  59. focus: 'series'
  60. },
  61. data: [1,1,10,30,35,0,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. });