MonthSale.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. Ext.define('saas.view.home.charts.MonthSale', {
  2. extend: 'saas.view.core.chart.ChartBase',
  3. xtype: 'month-sale',
  4. id: 'month_sale',
  5. title: '本月销售额(万元):0', // 设置默认标题占好默认高度,使容器内的组件可以正确获得展示高度
  6. bind: {
  7. title: '本月销售额(万元):{month_sale_amount}'
  8. },
  9. initComponent: function() {
  10. var me = this;
  11. Ext.apply(me, {
  12. items: [{
  13. xtype: 'echartsbase',
  14. bind: {
  15. store: '{month_sale}',
  16. },
  17. isEmpty: me.isEmpty,
  18. createOption: me.createOption
  19. }]
  20. });
  21. me.callParent(arguments);
  22. },
  23. isEmpty: function(store) {
  24. var index = store.findBy(function(s) {
  25. return s.get('y') > 0;
  26. });
  27. var flag = index == -1;
  28. return flag;
  29. },
  30. createOption: function(store) {
  31. var fields = [],
  32. data = [];
  33. store.each(function(d) {
  34. var d = d.data;
  35. if(d.y > 0) {
  36. fields.push(d.x);
  37. data.push({
  38. value: d.y,
  39. name: d.x
  40. });
  41. }
  42. });
  43. return {
  44. color: [
  45. '#1EC09F',
  46. '#27A7FF',
  47. '#4E84F5',
  48. '#FDC200',
  49. '#76DDFB',
  50. '#FE7D6B',
  51. ],
  52. tooltip: {
  53. trigger: 'item',
  54. formatter: function (params, ticket, callback) {
  55. var name = params.name,
  56. value = params.value,
  57. marker = params.marker,
  58. percent = params.percent;
  59. if(name.length > 7) {
  60. name = Ext.String.insert(name, '<br/>', 7)
  61. }
  62. value = saas.util.BaseUtil.numberFormat(value, 4, true);
  63. return name + '<br/>' + marker + value+ ' (' + percent + '%)';
  64. }
  65. },
  66. legend: {
  67. orient: 'vertical',
  68. left: '70%',
  69. width: '30%',
  70. icon: 'circle',
  71. data: fields,
  72. itemWidth: 9,
  73. itemHeight: 9
  74. },
  75. series: [
  76. {
  77. type:'pie',
  78. radius: ['48%', '88%'],
  79. center: ['35%', '50%'],
  80. label: {
  81. normal: {
  82. show: false,
  83. },
  84. emphasis: {
  85. show: false,
  86. textStyle: {
  87. fontSize: '30',
  88. fontWeight: 'bold'
  89. }
  90. }
  91. },
  92. labelLine: {
  93. normal: {
  94. show: false
  95. }
  96. },
  97. data: data
  98. }
  99. ]
  100. }
  101. }
  102. });