MonthSale.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. createOption: me.createOption
  18. }]
  19. });
  20. me.callParent(arguments);
  21. },
  22. createOption: function(store) {
  23. var fields = [],
  24. data = [];
  25. store.each(function(d) {
  26. var d = d.data;
  27. fields.push(d.x);
  28. data.push({
  29. value: d.y,
  30. name: d.x
  31. });
  32. });
  33. return {
  34. color: [
  35. '#1EC09F',
  36. '#27A7FF',
  37. '#4E84F5',
  38. '#FDC200',
  39. '#76DDFB',
  40. '#FE7D6B',
  41. ],
  42. tooltip: {
  43. trigger: 'item',
  44. formatter: function (params, ticket, callback) {
  45. var name = params.name,
  46. value = params.value,
  47. marker = params.marker,
  48. percent = params.percent;
  49. if(name.length > 7) {
  50. name = Ext.String.insert(name, '<br/>', 7)
  51. }
  52. value = saas.util.BaseUtil.numberFormat(value, 4, true);
  53. return name + '<br/>' + marker + value+ ' (' + percent + '%)';
  54. }
  55. },
  56. legend: {
  57. orient: 'horizontal',
  58. left: '70%',
  59. width: '30%',
  60. icon: 'circle',
  61. data: fields,
  62. itemWidth: 9,
  63. itemHeight: 9
  64. },
  65. series: [
  66. {
  67. type:'pie',
  68. radius: ['48%', '88%'],
  69. center: ['35%', '50%'],
  70. label: {
  71. normal: {
  72. show: false,
  73. },
  74. emphasis: {
  75. show: false,
  76. textStyle: {
  77. fontSize: '30',
  78. fontWeight: 'bold'
  79. }
  80. }
  81. },
  82. labelLine: {
  83. normal: {
  84. show: false
  85. }
  86. },
  87. data: data
  88. }
  89. ]
  90. }
  91. }
  92. });