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.
24 * {@img Ext.chart.axis.Numeric/Ext.chart.axis.Numeric.png Ext.chart.axis.Numeric chart axis}
28 * var store = Ext.create('Ext.data.JsonStore', {
29 * fields: ['name', 'data1', 'data2', 'data3', 'data4', 'data5'],
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}
39 * Ext.create('Ext.chart.Chart', {
40 * renderTo: Ext.getBody(),
48 * fields: ['data1', 'data2', 'data3', 'data4', 'data5'],
49 * title: 'Sample Values',
59 * adjustMinimumByMajorUnit: 0
64 * title: 'Sample Metrics',
77 * yField: ['data1', 'data2', 'data3', 'data4', 'data5'],
84 * In this example we create an axis of Numeric type. We set a minimum value so that
85 * even if all series have values greater than zero, the grid starts at zero. We bind
86 * the axis onto the left part of the surface by setting <em>position</em> to <em>left</em>.
87 * We bind three different store fields to this axis by setting <em>fields</em> to an array.
88 * We set the title of the axis to <em>Number of Hits</em> by using the <em>title</em> property.
89 * We use a <em>grid</em> configuration to set odd background rows to a certain style and even rows
90 * to be transparent/ignored.
93 Ext.define('Ext.chart.axis.Numeric', {
95 /* Begin Definitions */
97 extend: 'Ext.chart.axis.Axis',
99 alternateClassName: 'Ext.chart.NumericAxis',
101 /* End Definitions */
105 alias: 'axis.numeric',
107 constructor: function(config) {
109 hasLabel = !!(config.label && config.label.renderer),
112 me.callParent([config]);
114 if (me.roundToDecimal === false) {
118 label.renderer = function(v) {
119 return me.roundToDecimal(v, me.decimals);
124 roundToDecimal: function(v, dec) {
125 var val = Math.pow(10, dec || 0);
126 return ((v * val) >> 0) / val;
130 * The minimum value drawn by the axis. If not set explicitly, the axis
131 * minimum will be calculated automatically.
139 * The maximum value drawn by the axis. If not set explicitly, the axis
140 * maximum will be calculated automatically.
148 * The number of decimals to round the value to.
157 * The scaling algorithm to use on this axis. May be "linear" or
166 * Indicates the position of the axis relative to the chart
174 * Indicates whether to extend maximum beyond data's maximum to the nearest
177 * @property adjustMaximumByMajorUnit
180 adjustMaximumByMajorUnit: false,
183 * Indicates whether to extend the minimum beyond data's minimum to the
186 * @property adjustMinimumByMajorUnit
189 adjustMinimumByMajorUnit: false,
191 // @private apply data.
192 applyData: function() {
194 return this.calcEnds();