MonthPurchase.js 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. Ext.define('saas.view.home.charts.MonthPurchase', {
  2. extend: 'saas.view.core.chart.ChartBase',
  3. xtype: 'month-purchase',
  4. id: 'month_purchase',
  5. bind: {
  6. title: '本月采购额(万元):{month_purchase_amount}'
  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: '{month_purchase}',
  19. },
  20. axes: [{
  21. type: 'category',
  22. fields: ['x'],
  23. position: 'bottom',
  24. label: {
  25. fontSize: '12px',
  26. fillStyle: '#485465',
  27. },
  28. style: {
  29. fill: '#F7F8FA',
  30. strokeStyle: 'transparent'
  31. },
  32. renderer: me.onCategoryLabelRender
  33. },{
  34. type: 'numeric',
  35. fields: ['y'],
  36. position: 'left',
  37. adjustByMajorUnit: true,
  38. grid: {
  39. even: {
  40. stroke: '#F7F8FA'
  41. },
  42. odd: {
  43. stroke: '#F7F8FA',
  44. }
  45. },
  46. label: {
  47. fontSize: '12px',
  48. fillStyle: '#485465',
  49. textAlign: 'end'
  50. },
  51. style: {
  52. fill: '#fff',
  53. strokeStyle: 'transparent'
  54. },
  55. minimum: 0
  56. }],
  57. series: [{
  58. type: 'bar',
  59. xField: 'x',
  60. yField: ['y'],
  61. bind: {
  62. style: {
  63. lineWidth: 0,
  64. strokeStyle: 'transparent',
  65. maxBarWidth: '{maxBarWidth}',
  66. },
  67. },
  68. tooltip: {
  69. trackMouse: true,
  70. renderer: me.onBarTipRender
  71. }
  72. }]
  73. }]
  74. });
  75. me.callParent(arguments);
  76. },
  77. onCategoryLabelRender: function(axis, label, layoutContent, lastLabel) {
  78. return label.substr(0,2) + '...';
  79. },
  80. onBarTipRender: function (tooltip, record, item) {
  81. tooltip.setHtml(record.get('x') + ': ' + record.get('y') + '万元');
  82. },
  83. });