2 * @class Ext.chart.axis.Numeric
3 * @extends Ext.chart.axis.Axis
5 * An axis to handle numeric values. This axis is used for quantitative data as
6 * opposed to the category axis. You can set mininum and maximum values to the
7 * axis so that the values are bound to that. If no values are set, then the
8 * scale will auto-adjust to the values.
9 * {@img Ext.chart.axis.Numeric/Ext.chart.axis.Numeric.png Ext.chart.axis.Numeric chart axis}
13 var store = Ext.create('Ext.data.JsonStore', {
14 fields: ['name', 'data1', 'data2', 'data3', 'data4', 'data5'],
16 {'name':'metric one', 'data1':10, 'data2':12, 'data3':14, 'data4':8, 'data5':13},
17 {'name':'metric two', 'data1':7, 'data2':8, 'data3':16, 'data4':10, 'data5':3},
18 {'name':'metric three', 'data1':5, 'data2':2, 'data3':14, 'data4':12, 'data5':7},
19 {'name':'metric four', 'data1':2, 'data2':14, 'data3':6, 'data4':1, 'data5':23},
20 {'name':'metric five', 'data1':27, 'data2':38, 'data3':36, 'data4':13, 'data5':33}
24 Ext.create('Ext.chart.Chart', {
25 renderTo: Ext.getBody(),
33 fields: ['data1', 'data2', 'data3', 'data4', 'data5'],
34 title: 'Sample Values',
44 adjustMinimumByMajorUnit: 0
49 title: 'Sample Metrics',
62 yField: ['data1', 'data2', 'data3', 'data4', 'data5'],
71 * In this example we create an axis of Numeric type. We set a minimum value so that
72 * even if all series have values greater than zero, the grid starts at zero. We bind
73 * the axis onto the left part of the surface by setting <em>position</em> to <em>left</em>.
74 * We bind three different store fields to this axis by setting <em>fields</em> to an array.
75 * We set the title of the axis to <em>Number of Hits</em> by using the <em>title</em> property.
76 * We use a <em>grid</em> configuration to set odd background rows to a certain style and even rows
77 * to be transparent/ignored.
82 Ext.define('Ext.chart.axis.Numeric', {
84 /* Begin Definitions */
86 extend: 'Ext.chart.axis.Axis',
88 alternateClassName: 'Ext.chart.NumericAxis',
94 alias: 'axis.numeric',
96 constructor: function(config) {
97 var me = this, label, f;
98 me.callParent([config]);
100 if (me.roundToDecimal === false) {
103 if (label.renderer) {
105 label.renderer = function(v) {
106 return me.roundToDecimal( f(v), me.decimals );
109 label.renderer = function(v) {
110 return me.roundToDecimal(v, me.decimals);
115 roundToDecimal: function(v, dec) {
116 var val = Math.pow(10, dec || 0);
117 return ((v * val) >> 0) / val;
121 * The minimum value drawn by the axis. If not set explicitly, the axis
122 * minimum will be calculated automatically.
130 * The maximum value drawn by the axis. If not set explicitly, the axis
131 * maximum will be calculated automatically.
139 * The number of decimals to round the value to.
148 * The scaling algorithm to use on this axis. May be "linear" or
157 * Indicates the position of the axis relative to the chart
165 * Indicates whether to extend maximum beyond data's maximum to the nearest
168 * @property adjustMaximumByMajorUnit
171 adjustMaximumByMajorUnit: false,
174 * Indicates whether to extend the minimum beyond data's minimum to the
177 * @property adjustMinimumByMajorUnit
180 adjustMinimumByMajorUnit: false,
182 // @private apply data.
183 applyData: function() {
185 return this.calcEnds();