dashboard.js 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. data: result
  63. },
  64. ]
  65. };
  66. // 使用刚指定的配置项和数据显示图表。
  67. myChart.setOption(option);
  68. $(window).resize(function () {
  69. myChart.resize();
  70. });
  71. $(document).on("click", ".btn-refresh", function () {
  72. setTimeout(function () {
  73. myChart.resize();
  74. }, 0);
  75. });
  76. }
  77. });
  78. }
  79. };
  80. return Controller;
  81. });