3 This file is part of Ext JS 4
5 Copyright (c) 2011 Sencha Inc
7 Contact: http://www.sencha.com/contact
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.
12 If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.
16 * @class Ext.chart.axis.Numeric
17 * @extends Ext.chart.axis.Axis
19 * An axis to handle numeric values. This axis is used for quantitative data as
20 * opposed to the category axis. You can set mininum and maximum values to the
21 * axis so that the values are bound to that. If no values are set, then the
22 * scale will auto-adjust to the values.
25 * var store = Ext.create('Ext.data.JsonStore', {
26 * fields: ['name', 'data1', 'data2', 'data3', 'data4', 'data5'],
28 * {'name':'metric one', 'data1':10, 'data2':12, 'data3':14, 'data4':8, 'data5':13},
29 * {'name':'metric two', 'data1':7, 'data2':8, 'data3':16, 'data4':10, 'data5':3},
30 * {'name':'metric three', 'data1':5, 'data2':2, 'data3':14, 'data4':12, 'data5':7},
31 * {'name':'metric four', 'data1':2, 'data2':14, 'data3':6, 'data4':1, 'data5':23},
32 * {'name':'metric five', 'data1':27, 'data2':38, 'data3':36, 'data4':13, 'data5':33}
36 * Ext.create('Ext.chart.Chart', {
37 * renderTo: Ext.getBody(),
45 * fields: ['data1', 'data2', 'data3', 'data4', 'data5'],
46 * title: 'Sample Values',
56 * adjustMinimumByMajorUnit: 0
61 * title: 'Sample Metrics',
74 * yField: ['data1', 'data2', 'data3', 'data4', 'data5'],
81 * In this example we create an axis of Numeric type. We set a minimum value so that
82 * even if all series have values greater than zero, the grid starts at zero. We bind
83 * the axis onto the left part of the surface by setting `position` to `left`.
84 * We bind three different store fields to this axis by setting `fields` to an array.
85 * We set the title of the axis to _Number of Hits_ by using the `title` property.
86 * We use a `grid` configuration to set odd background rows to a certain style and even rows
87 * to be transparent/ignored.
89 Ext.define('Ext.chart.axis.Numeric', {
91 /* Begin Definitions */
93 extend: 'Ext.chart.axis.Axis',
95 alternateClassName: 'Ext.chart.NumericAxis',
101 alias: 'axis.numeric',
103 constructor: function(config) {
105 hasLabel = !!(config.label && config.label.renderer),
108 me.callParent([config]);
110 if (me.roundToDecimal === false) {
114 label.renderer = function(v) {
115 return me.roundToDecimal(v, me.decimals);
120 roundToDecimal: function(v, dec) {
121 var val = Math.pow(10, dec || 0);
122 return Math.floor(v * val) / val;
126 * The minimum value drawn by the axis. If not set explicitly, the axis
127 * minimum will be calculated automatically.
129 * @property {Number} minimum
134 * The maximum value drawn by the axis. If not set explicitly, the axis
135 * maximum will be calculated automatically.
137 * @property {Number} maximum
142 * The number of decimals to round the value to.
144 * @property {Number} decimals
149 * The scaling algorithm to use on this axis. May be "linear" or
150 * "logarithmic". Currently only linear scale is implemented.
152 * @property {String} scale
158 * Indicates the position of the axis relative to the chart
160 * @property {String} position
165 * Indicates whether to extend maximum beyond data's maximum to the nearest
168 * @property {Boolean} adjustMaximumByMajorUnit
170 adjustMaximumByMajorUnit: false,
173 * Indicates whether to extend the minimum beyond data's minimum to the
176 * @property {Boolean} adjustMinimumByMajorUnit
178 adjustMinimumByMajorUnit: false,
180 // @private apply data.
181 applyData: function() {
183 return this.calcEnds();