説明なし

index.js 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /**
  2. * Created by TT on 2017/4/6.
  3. */
  4. ;
  5. spa_define(function () {
  6. return $.use(["spa", "code", "form", "util", "dict"], function (spa, code, form, util, dict) {
  7. return {
  8. main: function () {
  9. var root = spa.findInMain(".sys_usercount_index");
  10. var cr = code.parseCode(root.find(".dt-tpl"));
  11. var myChart = echarts.init(document.getElementById('type'));
  12. var tableData = {data: []},
  13. allData = [];
  14. cr.shell("count", function (env) {
  15. var v = env.cd[this.k];
  16. if (v === 0) {
  17. return 0;
  18. }
  19. return v;
  20. });
  21. var query = function () {
  22. if (allData != null) {
  23. tableData.data = allData;
  24. }
  25. cr.val(tableData.data);
  26. };
  27. var load = function () {
  28. util.get("../ajax/operation/statist/userCount", null, function (data) {
  29. allData = data || [];
  30. query();
  31. var colors = ['#c23531', '#82C8FA'];
  32. var option = {
  33. color: colors,
  34. title: {
  35. text: '用户流量统计',
  36. subtext: '最近7天'
  37. },
  38. tooltip: {
  39. trigger: 'axis'
  40. },
  41. legend: {
  42. data: ['新增用户', '新增激活用户']
  43. },
  44. xAxis: {
  45. data: allData.map(function (item) {
  46. return item.createTime;
  47. }),
  48. boundaryGap: false
  49. },
  50. yAxis: {
  51. splitLine: {
  52. show: false
  53. },
  54. boundaryGap: false,
  55. type: "value",
  56. interval: 1,
  57. min: 0
  58. },
  59. toolbox: {
  60. show: true,
  61. feature: {
  62. dataZoom: {
  63. yAxisIndex: 'none'
  64. },
  65. dataView: {readOnly: true},
  66. magicType: {type: ['line', 'bar']},
  67. restore: {},
  68. saveAsImage: {}
  69. }
  70. },
  71. dataZoom: [{
  72. startValue: ""
  73. }, {
  74. type: 'inside'
  75. }],
  76. visualMap: {
  77. top: 10,
  78. right: 10,
  79. },
  80. series: [{
  81. name: '新增用户',
  82. type: 'line',
  83. data: allData.map(function (item) {
  84. return item.znum;
  85. }),
  86. }, {
  87. name: '新增激活用户',
  88. type: 'line',
  89. data: allData.map(function (item) {
  90. return item.jnum;
  91. })
  92. }
  93. ]
  94. };
  95. myChart.setOption(option);
  96. }, {});
  97. };
  98. cr.listen(dict.doTransfer);
  99. load();
  100. },
  101. mainDestory: function () {
  102. }
  103. };
  104. });
  105. });