PageRenderTime 88ms CodeModel.GetById 24ms RepoModel.GetById 1ms app.codeStats 0ms

/ext-4.0.7/examples/charts/AreaBrowserStats.js

https://bitbucket.org/srogerf/javascript
JavaScript | 330 lines | 309 code | 7 blank | 14 comment | 0 complexity | eeef849e04966f26661a0c202cef6722 MD5 | raw file
  1. /*
  2. This file is part of Ext JS 4
  3. Copyright (c) 2011 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 published by the Free Software Foundation and appearing in the file LICENSE included in the packaging of this file. Please review the following information to ensure the GNU General Public License version 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
  7. If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.
  8. */
  9. Ext.require('Ext.chart.*');
  10. Ext.require('Ext.data.*');
  11. Ext.require('Ext.Window');
  12. Ext.require('Ext.layout.container.Fit');
  13. Ext.require('Ext.fx.target.Sprite');
  14. var jsonData = [
  15. {
  16. date: '1/1/2009',
  17. IE: 44.8,
  18. Firefox: 45.5,
  19. Chrome: 3.9,
  20. Safari: 3,
  21. Opera: 2.3,
  22. Other: 0.5
  23. },
  24. {
  25. date: '2/1/2009',
  26. IE: 43.6,
  27. Firefox: 46.4,
  28. Chrome: 4,
  29. Safari: 3,
  30. Opera: 2.2,
  31. Other: 0.8
  32. },
  33. {
  34. date: '3/1/2009',
  35. IE: 43.3,
  36. Firefox: 46.5,
  37. Chrome: 4.2,
  38. Safari: 3.1,
  39. Opera: 2.3,
  40. Other: 0.6
  41. },
  42. {
  43. date: '4/1/2009',
  44. IE: 42.1,
  45. Firefox: 47.1,
  46. Chrome: 4.9,
  47. Safari: 3,
  48. Opera: 2.2,
  49. Other: 0.7
  50. },
  51. {
  52. date: '5/1/2009',
  53. IE: 41,
  54. Firefox: 47.7,
  55. Chrome: 5.5,
  56. Safari: 3,
  57. Opera: 2.2,
  58. Other: 0.6
  59. },
  60. {
  61. date: '6/1/2009',
  62. IE: 40.7,
  63. Firefox: 47.3,
  64. Chrome: 6,
  65. Safari: 3.1,
  66. Opera: 2.1,
  67. Other: 0.8
  68. },
  69. {
  70. date: '7/1/2009',
  71. IE: 39.4,
  72. Firefox: 47.9,
  73. Chrome: 6.5,
  74. Safari: 3.3,
  75. Opera: 2.1,
  76. Other: 0.8
  77. },
  78. {
  79. date: '8/1/2009',
  80. IE: 39.3,
  81. Firefox: 47.4,
  82. Chrome: 7,
  83. Safari: 3.3,
  84. Opera: 2.1,
  85. Other: 0.9
  86. },
  87. {
  88. date: '9/1/2009',
  89. IE: 39.6,
  90. Firefox: 46.6,
  91. Chrome: 7.1,
  92. Safari: 3.6,
  93. Opera: 2.2,
  94. Other: 0.9
  95. },
  96. {
  97. date: '10/1/2009',
  98. IE: 37.5,
  99. Firefox: 47.5,
  100. Chrome: 8,
  101. Safari: 3.8,
  102. Opera: 2.3,
  103. Other: 0.9
  104. },
  105. {
  106. date: '11/1/2009',
  107. IE: 37.7,
  108. Firefox: 47,
  109. Chrome: 8.5,
  110. Safari: 3.8,
  111. Opera: 2.3,
  112. Other: 0.7
  113. },
  114. {
  115. date: '12/1/2009',
  116. IE: 37.2,
  117. Firefox: 46.4,
  118. Chrome: 9.8,
  119. Safari: 3.6,
  120. Opera: 2.3,
  121. Other: 0.7
  122. },
  123. {
  124. date: '1/1/2010',
  125. IE: 36.2,
  126. Firefox: 46.3,
  127. Chrome: 10.8,
  128. Safari: 3.7,
  129. Opera: 2.2,
  130. Other: 0.8
  131. },
  132. {
  133. date: '2/1/2010',
  134. IE: 35.3,
  135. Firefox: 46.5,
  136. Chrome: 11.6,
  137. Safari: 3.8,
  138. Opera: 2.1,
  139. Other: 0.7
  140. },
  141. {
  142. date: '3/1/2010',
  143. IE: 34.9,
  144. Firefox: 46.2,
  145. Chrome: 12.3,
  146. Safari: 3.7,
  147. Opera: 2.2,
  148. Other: 0.7
  149. },
  150. {
  151. date: '4/1/2010',
  152. IE: 33.4,
  153. Firefox: 46.4,
  154. Chrome: 13.6,
  155. Safari: 3.7,
  156. Opera: 2.2,
  157. Other: 0.7
  158. },
  159. {
  160. date: '5/1/2010',
  161. IE: 32.2,
  162. Firefox: 46.9,
  163. Chrome: 14.5,
  164. Safari: 3.5,
  165. Opera: 2.2,
  166. Other: 0.7
  167. },
  168. {
  169. date: '6/1/2010',
  170. IE: 31,
  171. Firefox: 46.6,
  172. Chrome: 15.9,
  173. Safari: 3.6,
  174. Opera: 2.1,
  175. Other: 0.8
  176. },
  177. {
  178. date: '7/1/2010',
  179. IE: 30.4,
  180. Firefox: 46.4,
  181. Chrome: 16.7,
  182. Safari: 3.4,
  183. Opera: 2.3,
  184. Other: 0.8
  185. },
  186. {
  187. date: '8/1/2010',
  188. IE: 30.7,
  189. Firefox: 45.8,
  190. Chrome: 17,
  191. Safari: 3.5,
  192. Opera: 2.3,
  193. Other: 0.7
  194. },
  195. {
  196. date: '9/1/2010',
  197. IE: 31.1,
  198. Firefox: 45.1,
  199. Chrome: 17.3,
  200. Safari: 3.7,
  201. Opera: 2.2,
  202. Other: 0.6
  203. },
  204. {
  205. date: '10/1/2010',
  206. IE: 29.7,
  207. Firefox: 44.1,
  208. Chrome: 19.2,
  209. Safari: 3.9,
  210. Opera: 2.2,
  211. Other: 0.9
  212. },
  213. {
  214. date: '11/1/2010',
  215. IE: 28.6,
  216. Firefox: 44,
  217. Chrome: 20.5,
  218. Safari: 4.0,
  219. Opera: 2.3,
  220. Other: 0.6
  221. },
  222. {
  223. date: '12/1/2010',
  224. IE: 27.5,
  225. Firefox: 43.5,
  226. Chrome: 22.4,
  227. Safari: 3.8,
  228. Opera: 2.2,
  229. Other: 0.6
  230. }
  231. ];
  232. Ext.onReady(function () {
  233. var fields = ['IE', 'Chrome', 'Firefox', 'Safari', 'Opera', 'Other'];
  234. var browserStore = Ext.create('Ext.data.JsonStore', {
  235. fields: fields,
  236. data: jsonData
  237. });
  238. var colors = ['rgb(47, 162, 223)',
  239. 'rgb(60, 133, 46)',
  240. 'rgb(234, 102, 17)',
  241. 'rgb(154, 176, 213)',
  242. 'rgb(186, 10, 25)',
  243. 'rgb(40, 40, 40)'];
  244. Ext.chart.theme.Browser = Ext.extend(Ext.chart.theme.Base, {
  245. constructor: function(config) {
  246. Ext.chart.theme.Base.prototype.constructor.call(this, Ext.apply({
  247. colors: colors
  248. }, config));
  249. }
  250. });
  251. var win = Ext.create('Ext.Window', {
  252. width: 800,
  253. height: 600,
  254. minHeight: 400,
  255. minWidth: 550,
  256. hidden: false,
  257. shadow: false,
  258. maximizable: false,
  259. title: 'What is the trend in Browser Usage?',
  260. renderTo: Ext.getBody(),
  261. layout: 'fit',
  262. items: {
  263. id: 'chartCmp',
  264. xtype: 'chart',
  265. style: 'background:#fff',
  266. animate: true,
  267. theme: 'Browser:gradients',
  268. defaultInsets: 30,
  269. store: browserStore,
  270. legend: {
  271. position: 'right'
  272. },
  273. axes: [{
  274. type: 'Numeric',
  275. position: 'left',
  276. fields: fields,
  277. title: 'Usage %',
  278. grid: true,
  279. decimals: 0,
  280. minimum: 0,
  281. maximum: 100
  282. }, {
  283. type: 'Category',
  284. position: 'bottom',
  285. fields: ['date'],
  286. title: 'Month of the Year',
  287. label: {
  288. renderer: function(v) {
  289. return v.match(/([0-9]*)\/[0-9]*\/[0-9][0-9]([0-9]*)/).slice(1).join('/');
  290. }
  291. }
  292. }],
  293. series: [{
  294. type: 'area',
  295. axis: 'left',
  296. highlight: true,
  297. tips: {
  298. trackMouse: true,
  299. width: 170,
  300. height: 28,
  301. renderer: function(storeItem, item) {
  302. this.setTitle(item.storeField + ' - '
  303. + Ext.Date.format(new Date(storeItem.get('date')), 'M y')
  304. + ' - ' + storeItem.get(item.storeField) + '%');
  305. }
  306. },
  307. xField: 'name',
  308. yField: fields,
  309. style: {
  310. lineWidth: 1,
  311. stroke: '#666',
  312. opacity: 0.86
  313. }
  314. }]
  315. }
  316. });
  317. });