You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

169 lines
5.4 KiB

2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. This file is part of Ext JS 3.4
  3. Copyright (c) 2011-2013 Sencha Inc
  4. Contact: http://www.sencha.com/contact
  5. GNU General Public License Usage
  6. This file may be used under the terms of the GNU General Public License version 3.0 as
  7. published by the Free Software Foundation and appearing in the file LICENSE included in the
  8. packaging of this file.
  9. Please review the following information to ensure the GNU General Public License version 3.0
  10. requirements will be met: http://www.gnu.org/copyleft/gpl.html.
  11. If you are unsure which license is appropriate for your use, please contact the sales department
  12. at http://www.sencha.com/contact.
  13. Build date: 2013-04-03 15:07:25
  14. */
  15. Ext.chart.Chart.CHART_URL = '../../resources/charts.swf';
  16. Ext.onReady(function(){
  17. var store = new Ext.data.JsonStore({
  18. fields:['name', 'visits', 'views'],
  19. data: [
  20. {name:'Jul 07', visits: 245000, views: 3000000},
  21. {name:'Aug 07', visits: 240000, views: 3500000},
  22. {name:'Sep 07', visits: 355000, views: 4000000},
  23. {name:'Oct 07', visits: 375000, views: 4200000},
  24. {name:'Nov 07', visits: 490000, views: 4500000},
  25. {name:'Dec 07', visits: 495000, views: 5800000},
  26. {name:'Jan 08', visits: 520000, views: 6000000},
  27. {name:'Feb 08', visits: 620000, views: 7500000}
  28. ]
  29. });
  30. // extra extra simple
  31. new Ext.Panel({
  32. title: 'ExtJS.com Visits Trend, 2007/2008 (No styling)',
  33. renderTo: 'container',
  34. width:500,
  35. height:300,
  36. layout:'fit',
  37. items: {
  38. xtype: 'linechart',
  39. store: store,
  40. xField: 'name',
  41. yField: 'visits',
  42. listeners: {
  43. itemclick: function(o){
  44. var rec = store.getAt(o.index);
  45. Ext.example.msg('Item Selected', 'You chose {0}.', rec.get('name'));
  46. }
  47. }
  48. }
  49. });
  50. // extra simple
  51. new Ext.Panel({
  52. iconCls:'chart',
  53. title: 'ExtJS.com Visits Trend, 2007/2008 (Simple styling)',
  54. frame:true,
  55. renderTo: 'container',
  56. width:500,
  57. height:300,
  58. layout:'fit',
  59. items: {
  60. xtype: 'linechart',
  61. store: store,
  62. url: '../../resources/charts.swf',
  63. xField: 'name',
  64. yField: 'visits',
  65. yAxis: new Ext.chart.NumericAxis({
  66. displayName: 'Visits',
  67. labelRenderer : Ext.util.Format.numberRenderer('0,0')
  68. }),
  69. tipRenderer : function(chart, record){
  70. return Ext.util.Format.number(record.data.visits, '0,0') + ' visits in ' + record.data.name;
  71. }
  72. }
  73. });
  74. // more complex with a custom look
  75. new Ext.Panel({
  76. iconCls:'chart',
  77. title: 'ExtJS.com Visits and Pageviews, 2007/2008 (Full styling)',
  78. frame:true,
  79. renderTo: 'container',
  80. width:500,
  81. height:300,
  82. layout:'fit',
  83. items: {
  84. xtype: 'columnchart',
  85. store: store,
  86. url:'../../resources/charts.swf',
  87. xField: 'name',
  88. yAxis: new Ext.chart.NumericAxis({
  89. displayName: 'Visits',
  90. labelRenderer : Ext.util.Format.numberRenderer('0,0')
  91. }),
  92. tipRenderer : function(chart, record, index, series){
  93. if(series.yField == 'visits'){
  94. return Ext.util.Format.number(record.data.visits, '0,0') + ' visits in ' + record.data.name;
  95. }else{
  96. return Ext.util.Format.number(record.data.views, '0,0') + ' page views in ' + record.data.name;
  97. }
  98. },
  99. chartStyle: {
  100. padding: 10,
  101. animationEnabled: true,
  102. font: {
  103. name: 'Tahoma',
  104. color: 0x444444,
  105. size: 11
  106. },
  107. dataTip: {
  108. padding: 5,
  109. border: {
  110. color: 0x99bbe8,
  111. size:1
  112. },
  113. background: {
  114. color: 0xDAE7F6,
  115. alpha: .9
  116. },
  117. font: {
  118. name: 'Tahoma',
  119. color: 0x15428B,
  120. size: 10,
  121. bold: true
  122. }
  123. },
  124. xAxis: {
  125. color: 0x69aBc8,
  126. majorTicks: {color: 0x69aBc8, length: 4},
  127. minorTicks: {color: 0x69aBc8, length: 2},
  128. majorGridLines: {size: 1, color: 0xeeeeee}
  129. },
  130. yAxis: {
  131. color: 0x69aBc8,
  132. majorTicks: {color: 0x69aBc8, length: 4},
  133. minorTicks: {color: 0x69aBc8, length: 2},
  134. majorGridLines: {size: 1, color: 0xdfe8f6}
  135. }
  136. },
  137. series: [{
  138. type: 'column',
  139. displayName: 'Page Views',
  140. yField: 'views',
  141. style: {
  142. image:'bar.gif',
  143. mode: 'stretch',
  144. color:0x99BBE8
  145. }
  146. },{
  147. type:'line',
  148. displayName: 'Visits',
  149. yField: 'visits',
  150. style: {
  151. color: 0x15428B
  152. }
  153. }]
  154. }
  155. });
  156. });