Upgrade to ExtJS 4.0.7 - Released 10/19/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         minHeight: 400,
45         minWidth: 550,
46         hidden: false,
47         maximizable: true,
48         title: 'Bar Chart',
49         renderTo: Ext.getBody(),
50         layout: 'fit',
51         tbar: [{
52             text: 'Reload Data',
53             handler: function() {
54                 store1.loadData(generateData());
55             }
56         }],
57         items: {
58             id: 'chartCmp',
59             xtype: 'chart',
60             animate: true,
61             shadow: true,
62             store: store1,
63             axes: [{
64                 type: 'Numeric',
65                 position: 'bottom',
66                 fields: ['data1'],
67                 label: {
68                     renderer: Ext.util.Format.numberRenderer('0,0')
69                 },
70                 title: 'Number of Hits',
71                 grid: true,
72                 minimum: 0
73             }, {
74                 type: 'Category',
75                 position: 'left',
76                 fields: ['name'],
77                 title: 'Month of the Year'
78             }],
79             theme: 'White',
80             background: {
81               gradient: {
82                 id: 'backgroundGradient',
83                 angle: 45,
84                 stops: {
85                   0: {
86                     color: '#ffffff'
87                   },
88                   100: {
89                     color: '#eaf1f8'
90                   }
91                 }
92               }
93             },
94             series: [{
95                 type: 'bar',
96                 axis: 'bottom',
97                 highlight: true,
98                 tips: {
99                   trackMouse: true,
100                   width: 140,
101                   height: 28,
102                   renderer: function(storeItem, item) {
103                     this.setTitle(storeItem.get('name') + ': ' + storeItem.get('data1') + ' views');
104                   }
105                 },
106                 label: {
107                   display: 'insideEnd',
108                     field: 'data1',
109                     renderer: Ext.util.Format.numberRenderer('0'),
110                     orientation: 'horizontal',
111                     color: '#333',
112                   'text-anchor': 'middle'
113                 },
114                 xField: 'name',
115                 yField: ['data1']
116             }]
117         }
118     });
119 });
120