Upgrade to ExtJS 4.0.2 - Released 06/09/2011
[extjs.git] / examples / charts / Bar.js
1 /*
2
3 This file is part of Ext JS 4
4
5 Copyright (c) 2011 Sencha Inc
6
7 Contact:  http://www.sencha.com/contact
8
9 GNU General Public License Usage
10 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.
11
12 If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.
13
14 */
15 Ext.require('Ext.chart.*');
16 Ext.require(['Ext.Window', 'Ext.fx.target.Sprite', 'Ext.layout.container.Fit']);
17
18 Ext.onReady(function () {
19     Ext.chart.theme.White = Ext.extend(Ext.chart.theme.Base, {
20         constructor: function() {
21            Ext.chart.theme.White.superclass.constructor.call(this, {
22                axis: {
23                    stroke: 'rgb(8,69,148)',
24                    'stroke-width': 1
25                },
26                axisLabel: {
27                    fill: 'rgb(8,69,148)',
28                    font: '12px Arial',
29                    'font-family': '"Arial',
30                    spacing: 2,
31                    padding: 5,
32                    renderer: function(v) { return v; }
33                },
34                axisTitle: {
35                   font: 'bold 18px Arial'
36                }
37            });
38         }
39     });
40
41     var win = Ext.create('Ext.Window', {
42         width: 800,
43         height: 600,
44         hidden: false,
45         maximizable: true,
46         title: 'Bar Chart',
47         renderTo: Ext.getBody(),
48         layout: 'fit',
49         tbar: [{
50             text: 'Reload Data',
51             handler: function() {
52                 store1.loadData(generateData());
53             }
54         }],
55         items: {
56             id: 'chartCmp',
57             xtype: 'chart',
58             animate: true,
59             shadow: true,
60             store: store1,
61             axes: [{
62                 type: 'Numeric',
63                 position: 'bottom',
64                 fields: ['data1'],
65                 label: {
66                     renderer: Ext.util.Format.numberRenderer('0,0')
67                 },
68                 title: 'Number of Hits',
69                 grid: true,
70                 minimum: 0
71             }, {
72                 type: 'Category',
73                 position: 'left',
74                 fields: ['name'],
75                 title: 'Month of the Year'
76             }],
77             theme: 'White',
78             background: {
79               gradient: {
80                 id: 'backgroundGradient',
81                 angle: 45,
82                 stops: {
83                   0: {
84                     color: '#ffffff'
85                   },
86                   100: {
87                     color: '#eaf1f8'
88                   }
89                 }
90               }
91             },
92             series: [{
93                 type: 'bar',
94                 axis: 'bottom',
95                 highlight: true,
96                 tips: {
97                   trackMouse: true,
98                   width: 140,
99                   height: 28,
100                   renderer: function(storeItem, item) {
101                     this.setTitle(storeItem.get('name') + ': ' + storeItem.get('data1') + ' views');
102                   }
103                 },
104                 label: {
105                   display: 'insideEnd',
106                     field: 'data1',
107                     renderer: Ext.util.Format.numberRenderer('0'),
108                     orientation: 'horizontal',
109                     color: '#333',
110                   'text-anchor': 'middle'
111                 },
112                 xField: 'name',
113                 yField: ['data1']
114             }]
115         }
116     });
117 });
118