Summary.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. Ext.define('PageAnalyzer.Summary', {
  2. extend: 'Ext.panel.Panel',
  3. requires: [
  4. 'Ext.chart.*',
  5. 'Ext.grid.Panel',
  6. 'Ext.grid.feature.Grouping',
  7. 'Ext.layout.container.Border',
  8. 'PageAnalyzer.models.LayoutTypeSummaryData',
  9. 'PageAnalyzer.models.LayoutIdSummaryData',
  10. 'Ext.tab.Panel'
  11. ],
  12. layout: 'fit',
  13. border: false,
  14. toolTipTpl: [
  15. 'layout type: {type}<br/>',
  16. 'total time: {duration}<br/>',
  17. 'calls: {count}<br/>',
  18. 'avg. time: {[Math.round((values.duration / values.count) * 100) / 100]}<br/>',
  19. 'instances: {layoutCount}'
  20. ],
  21. initComponent: function () {
  22. var me = this;
  23. me.typeDurationStore = Ext.create('Ext.data.Store', {
  24. model: 'PageAnalyzer.models.LayoutTypeSummaryData',
  25. sorters: { property: 'type', direction: 'DESC' }
  26. });
  27. me.items = [{
  28. xtype: 'tabpanel',
  29. deferredRender: false,
  30. items:[
  31. me.makeTypeTimeSummaryChart({}),
  32. me.makeTypeCountSummaryChart({})
  33. ]
  34. }];
  35. me.callParent();
  36. },
  37. makeTypeTimeSummaryChart: function(cfg) {
  38. var me = this,
  39. toolTipTpl = me.getTpl('toolTipTpl');
  40. return Ext.apply({
  41. xtype: 'chart',
  42. store: me.typeDurationStore,
  43. itemId: 'durationsByTypeChart',
  44. title: 'Time By Layout Type',
  45. theme: 'Base:gradients',
  46. hideMode: 'offsets',
  47. axes: [{
  48. type: 'Numeric',
  49. title: 'Time (ms)',
  50. position: 'left',
  51. fields: ['duration'],
  52. grid: true
  53. },{
  54. type: 'Category',
  55. position: 'bottom',
  56. fields: ['type'],
  57. title: 'Layout Type',
  58. label:{
  59. 'text-anchor': 'middle',
  60. rotate: {
  61. degrees: -35
  62. },
  63. translate: {
  64. x: 10,
  65. y: 0
  66. }
  67. }
  68. }],
  69. series: [{
  70. type: 'column',
  71. axis: 'left',
  72. label: {
  73. field: 'type',
  74. font: '12px Arial'
  75. },
  76. tips: {
  77. trackMouse: true,
  78. tpl: toolTipTpl,
  79. renderer: function(storeItem, item) {
  80. this.update(storeItem.data);
  81. }
  82. },
  83. xField: 'type',
  84. yField: 'duration'
  85. }]
  86. }, cfg);
  87. },
  88. makeTypeCountSummaryChart: function(cfg) {
  89. var me = this,
  90. toolTipTpl = me.getTpl('toolTipTpl');
  91. return Ext.apply({
  92. xtype: 'chart',
  93. store: me.typeDurationStore,
  94. itemId: 'countsByTypeChart',
  95. title: 'Calls by Layout Type',
  96. theme: 'Base:gradients',
  97. hideMode: 'offsets',
  98. axes: [{
  99. type: 'Numeric',
  100. title: 'Total Calls',
  101. position: 'left',
  102. fields: ['count'],
  103. grid: true
  104. }, {
  105. type: 'Category',
  106. position: 'bottom',
  107. fields: ['type'],
  108. title: 'Layout Type',
  109. label:{
  110. 'text-anchor': 'middle',
  111. rotate: {
  112. degrees: -35
  113. },
  114. translate: {
  115. x: 10,
  116. y: 0
  117. }
  118. }
  119. }],
  120. series: [{
  121. type: 'column',
  122. axis: 'left',
  123. label: {
  124. field: 'type',
  125. font: '12px Arial'
  126. },
  127. tips: {
  128. trackMouse: true,
  129. tpl: toolTipTpl,
  130. renderer: function(storeItem, item) {
  131. this.update(storeItem.data);
  132. }
  133. },
  134. xField: 'type',
  135. yField: 'count'
  136. }]
  137. }, cfg);
  138. },
  139. loadTypeSummary: function (summary) {
  140. var me = this,
  141. data = [];
  142. Ext.Object.each(summary, function (type, sum){
  143. data.push({
  144. type: type,
  145. duration: sum.duration,
  146. count: sum.count,
  147. layoutCount: sum.layoutCount
  148. });
  149. });
  150. me.typeDurationStore.removeAll();
  151. me.typeDurationStore.loadData(data);
  152. me.typeDurationStore.sort();
  153. }
  154. });