PurchaseTrend.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. Ext.define('saas.view.home.charts.PurchaseTrend', {
  2. extend: 'saas.view.core.chart.ChartBase',
  3. xtype: 'purchase-trend',
  4. id: 'purchase_trend',
  5. bind: {
  6. title: '近六月采购趋势图'
  7. },
  8. initComponent: function() {
  9. var me = this;
  10. Ext.apply(me, {
  11. items: [{
  12. xtype: 'cartesian',
  13. colors: [
  14. '#34BAF6'
  15. ],
  16. bind: {
  17. insetPadding: '{insetPadding}',
  18. store: '{purchase_trend}',
  19. },
  20. axes: [{
  21. // title: {
  22. // text: '月',
  23. // fontSize: 14,
  24. // },
  25. type: 'category',
  26. fields: ['x'],
  27. position: 'bottom',
  28. label: {
  29. fillStyle: '#485465'
  30. },
  31. style: {
  32. fill: '#F7F8FA',
  33. strokeStyle: 'transparent'
  34. },
  35. renderer: me.categoryRender
  36. },{
  37. type: 'numeric',
  38. fields: ['y'],
  39. position: 'left',
  40. grid: {
  41. even: {
  42. stroke: '#F7F8FA'
  43. },
  44. odd: {
  45. stroke: '#F7F8FA',
  46. }
  47. },
  48. label: {
  49. fillStyle: '#485465'
  50. },
  51. style: {
  52. fill: '#fff',
  53. strokeStyle: 'transparent'
  54. },
  55. }],
  56. series: [{
  57. type: 'bar',
  58. xField: 'x',
  59. yField: ['y'],
  60. tooltip: {
  61. trackMouse: true,
  62. renderer: me.onBarTipRender
  63. },
  64. // label: {
  65. // field: 'y',
  66. // display: 'insideEnd',
  67. // fontSize: '12px',
  68. // strokeStyle: '#fff',
  69. // },
  70. bind: {
  71. style: {
  72. lineWidth: 0,
  73. strokeStyle: 'transparent',
  74. maxBarWidth: '{maxBarWidth}',
  75. },
  76. },
  77. }]
  78. }]
  79. });
  80. me.callParent(arguments);
  81. },
  82. onBarTipRender: function (tooltip, record, item) {
  83. tooltip.setHtml(record.get('x') + '月: ' + record.get('y') + '万元');
  84. },
  85. categoryRender: function(axis, label, layoutContext, lastLabel) {
  86. return label + '月';
  87. }
  88. });