Chart1.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. Ext.define('school.view.analysis.consumption.Chart1', {
  2. extend: 'school.view.core.chart.ChartBase',
  3. xtype: 'consumption-chart1',
  4. title: '各年级学生月校园平均消费统计',
  5. initComponent: function () {
  6. var me = this;
  7. Ext.apply(me, {
  8. items: [{
  9. xtype: 'echartsbase',
  10. bind: {
  11. store: '{chart1}',
  12. },
  13. createOption: me.createOption.bind(me)
  14. }]
  15. });
  16. me.callParent(arguments);
  17. },
  18. createOption: function (store) {
  19. var me = this,
  20. fields = [],
  21. gFields = ['初一', '初二', '初三'],
  22. g1 = [],
  23. g2 = [],
  24. g3 = [],
  25. gDatas = [],
  26. o;
  27. store.each(function (d) {
  28. var d = d.data;
  29. fields.push(d.month);
  30. g1.push(d.g1);
  31. g2.push(d.g2);
  32. g3.push(d.g3);
  33. });
  34. gDatas.push(g1, g2, g3);
  35. o = {
  36. color: [
  37. '#1EC09F',
  38. '#27A7FF',
  39. '#4E84F5',
  40. '#FDC200',
  41. '#76DDFB',
  42. '#FE7D6B',
  43. ],
  44. grid: {
  45. left: 0,
  46. right: 0,
  47. top: 60,
  48. bottom: 5,
  49. borderColor: '#E5EAEF',
  50. containLabel: true
  51. },
  52. tooltip : {
  53. trigger: 'axis',
  54. axisPointer : {
  55. type : 'shadow'
  56. }
  57. },
  58. legend: {
  59. data: gFields
  60. },
  61. xAxis: {
  62. type: 'category',
  63. axisLine: {
  64. lineStyle: {
  65. color: '#E5EAEF',
  66. }
  67. },
  68. axisLabel: {
  69. color: '#485465',
  70. interval: 0
  71. },
  72. data: fields,
  73. },
  74. yAxis: {
  75. type: 'value',
  76. axisLine: {
  77. lineStyle: {
  78. color: '#E5EAEF',
  79. }
  80. },
  81. splitLine: {
  82. lineStyle: {
  83. color: ['#E5EAEF']
  84. }
  85. },
  86. axisLabel: {
  87. color: '#485465'
  88. }
  89. },
  90. series: me.getSeries(gFields, gDatas)
  91. };
  92. return o;
  93. },
  94. getSeries: function(fields, datas) {
  95. let series = [];
  96. for(let i = fields.length - 1; i >= 0 ; i--) {
  97. let s = {
  98. name: fields[i],
  99. type: 'line',
  100. label: {
  101. normal: {
  102. show: true
  103. }
  104. },
  105. data: datas[i]
  106. };
  107. series.push(s);
  108. }
  109. return series;
  110. }
  111. });