dashboard.js 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. // 基于准备好的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: ['溯源码','订单']
  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: '溯源码',
  47. type: 'line',
  48. smooth: true,
  49. areaStyle: {
  50. normal: {}
  51. },
  52. lineStyle: {
  53. normal: {
  54. width: 1.5
  55. }
  56. },
  57. data: Config.codelistdata
  58. },
  59. {
  60. name: '订单',
  61. type: 'line',
  62. smooth: true,
  63. areaStyle: {
  64. normal: {}
  65. },
  66. lineStyle: {
  67. normal: {
  68. width: 1.5
  69. }
  70. },
  71. data: Config.orderlistdata
  72. }]
  73. };
  74. // 使用刚指定的配置项和数据显示图表。
  75. myChart.setOption(option);
  76. $(window).resize(function () {
  77. myChart.resize();
  78. });
  79. $(document).on("click", ".btn-refresh", function () {
  80. setTimeout(function () {
  81. myChart.resize();
  82. }, 0);
  83. });
  84. }
  85. };
  86. return Controller;
  87. });