dashboard.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. var that = this;
  5. var myChart = Echarts.init(document.getElementById('echart'), 'walden');
  6. Fast.api.ajax({
  7. url: window.Config.moduleurl+"/csminvite/dashboard/indexChartDataset",
  8. type: "get",
  9. }, function (data, ret) {
  10. var option = that._option(data);
  11. myChart.setOption(option);
  12. return false;
  13. }, function (data, ret) {
  14. return false;
  15. });
  16. $(window).resize(function () {
  17. myChart.resize();
  18. });
  19. $(document).on("click", ".btn-refresh", function () {
  20. window.location.reload();
  21. });
  22. },
  23. _option:function(data){
  24. console.log(data.dataset);
  25. var source2 = [];
  26. for(var item in data.dataset){
  27. source2.push(data.dataset[item]);
  28. }
  29. var option = {
  30. legend: {},
  31. tooltip: {},
  32. dataset: {
  33. // 提供一份数据。
  34. source: source2
  35. },
  36. grid:{
  37. left:50,
  38. right:0,
  39. top:50,
  40. bottom:50
  41. },
  42. color: ['#EC7366', '#1BDAB4', '#50a6e0','#918EC3'],
  43. // 声明一个 X 轴,类目轴(category)。默认情况下,类目轴对应到 dataset 第一列。
  44. xAxis: {type: 'category'},
  45. // 声明一个 Y 轴,数值轴。
  46. yAxis: {},
  47. // 声明多个 bar 系列,默认情况下,每个系列会自动对应到 dataset 的每一列。
  48. series: [
  49. {type: 'bar', barWidth : 15},
  50. {type: 'bar', barWidth : 15},
  51. {type: 'bar', barWidth : 15},
  52. {type: 'bar', barWidth : 15}
  53. ]
  54. };
  55. return option;
  56. }
  57. };
  58. return Controller;
  59. });