Upgrade to ExtJS 4.0.2 - Released 06/09/2011
[extjs.git] / src / chart / series / Column.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 /**
16  * @class Ext.chart.series.Column
17  * @extends Ext.chart.series.Bar
18  * 
19  * Creates a Column Chart. Much of the methods are inherited from Bar. A Column Chart is a useful visualization technique to display quantitative information for different 
20  * categories that can show some progression (or regression) in the data set.
21  * As with all other series, the Column Series must be appended in the *series* Chart array configuration. See the Chart 
22  * documentation for more information. A typical configuration object for the column series could be:
23  *
24  * {@img Ext.chart.series.Column/Ext.chart.series.Column.png Ext.chart.series.Column chart series}
25  *
26  * ## Example
27  * 
28  *     var store = Ext.create('Ext.data.JsonStore', {
29  *         fields: ['name', 'data1', 'data2', 'data3', 'data4', 'data5'],
30  *         data: [
31  *             {'name':'metric one', 'data1':10, 'data2':12, 'data3':14, 'data4':8, 'data5':13},
32  *             {'name':'metric two', 'data1':7, 'data2':8, 'data3':16, 'data4':10, 'data5':3},
33  *             {'name':'metric three', 'data1':5, 'data2':2, 'data3':14, 'data4':12, 'data5':7},
34  *             {'name':'metric four', 'data1':2, 'data2':14, 'data3':6, 'data4':1, 'data5':23},
35  *             {'name':'metric five', 'data1':27, 'data2':38, 'data3':36, 'data4':13, 'data5':33}                                                
36  *         ]
37  *     });
38  *     
39  *     Ext.create('Ext.chart.Chart', {
40  *         renderTo: Ext.getBody(),
41  *         width: 500,
42  *         height: 300,
43  *         animate: true,
44  *         store: store,
45  *         axes: [{
46  *             type: 'Numeric',
47  *             position: 'bottom',
48  *             fields: ['data1'],
49  *             label: {
50  *                 renderer: Ext.util.Format.numberRenderer('0,0')
51  *             },
52  *             title: 'Sample Values',
53  *             grid: true,
54  *             minimum: 0
55  *         }, {
56  *             type: 'Category',
57  *             position: 'left',
58  *             fields: ['name'],
59  *             title: 'Sample Metrics'
60  *         }],
61  *             axes: [{
62  *                 type: 'Numeric',
63  *                 position: 'left',
64  *                 fields: ['data1'],
65  *                 label: {
66  *                     renderer: Ext.util.Format.numberRenderer('0,0')
67  *                 },
68  *                 title: 'Sample Values',
69  *                 grid: true,
70  *                 minimum: 0
71  *             }, {
72  *                 type: 'Category',
73  *                 position: 'bottom',
74  *                 fields: ['name'],
75  *                 title: 'Sample Metrics'
76  *             }],
77  *             series: [{
78  *                 type: 'column',
79  *                 axis: 'left',
80  *                 highlight: true,
81  *                 tips: {
82  *                   trackMouse: true,
83  *                   width: 140,
84  *                   height: 28,
85  *                   renderer: function(storeItem, item) {
86  *                     this.setTitle(storeItem.get('name') + ': ' + storeItem.get('data1') + ' $');
87  *                   }
88  *                 },
89  *                 label: {
90  *                   display: 'insideEnd',
91  *                   'text-anchor': 'middle',
92  *                     field: 'data1',
93  *                     renderer: Ext.util.Format.numberRenderer('0'),
94  *                     orientation: 'vertical',
95  *                     color: '#333'
96  *                 },
97  *                 xField: 'name',
98  *                 yField: 'data1'
99  *             }]
100  *     });
101  *  
102  * In this configuration we set `column` as the series type, bind the values of the bars to the bottom axis, set `highlight` to true so that bars are smoothly highlighted
103  * when hovered and bind the `xField` or category field to the data store `name` property and the `yField` as the data1 property of a store element. 
104  */
105 Ext.define('Ext.chart.series.Column', {
106
107     /* Begin Definitions */
108
109     alternateClassName: ['Ext.chart.ColumnSeries', 'Ext.chart.ColumnChart', 'Ext.chart.StackedColumnChart'],
110
111     extend: 'Ext.chart.series.Bar',
112
113     /* End Definitions */
114
115     type: 'column',
116     alias: 'series.column',
117
118     column: true,
119
120     /**
121      * @cfg {Number} xPadding
122      * Padding between the left/right axes and the bars
123      */
124     xPadding: 10,
125
126     /**
127      * @cfg {Number} yPadding
128      * Padding between the top/bottom axes and the bars
129      */
130     yPadding: 0
131 });