dashboard.js 3.2 KB

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