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.Radial
17 * @extends Ext.chart.axis.Abstract
20 Ext.define('Ext.chart.axis.Radial', {
22 /* Begin Definitions */
24 extend: 'Ext.chart.axis.Abstract',
32 drawAxis: function(init) {
33 var chart = this.chart,
34 surface = chart.surface,
35 bbox = chart.chartBBox,
38 centerX = bbox.x + (bbox.width / 2),
39 centerY = bbox.y + (bbox.height / 2),
40 rho = Math.min(bbox.width, bbox.height) /2,
43 i, j, pi2 = Math.PI * 2,
44 cos = Math.cos, sin = Math.sin;
46 if (this.sprites && !chart.resizing) {
53 for (i = 1; i <= steps; i++) {
54 sprite = surface.add({
58 radius: Math.max(rho * i / steps, 0),
61 sprite.setAttributes({
67 store.each(function(rec, i) {
68 sprite = surface.add({
70 path: ['M', centerX, centerY, 'L', centerX + rho * cos(i / l * pi2), centerY + rho * sin(i / l * pi2), 'Z'],
73 sprite.setAttributes({
79 sprites = this.sprites;
81 for (i = 0; i < steps; i++) {
82 sprites[i].setAttributes({
85 radius: Math.max(rho * (i + 1) / steps, 0),
90 store.each(function(rec, j) {
91 sprites[i + j].setAttributes({
92 path: ['M', centerX, centerY, 'L', centerX + rho * cos(j / l * pi2), centerY + rho * sin(j / l * pi2), 'Z'],
97 this.sprites = sprites;
102 drawLabel: function() {
103 var chart = this.chart,
104 surface = chart.surface,
105 bbox = chart.chartBBox,
107 centerX = bbox.x + (bbox.width / 2),
108 centerY = bbox.y + (bbox.height / 2),
109 rho = Math.min(bbox.width, bbox.height) /2,
110 max = Math.max, round = Math.round,
111 labelArray = [], label,
112 fields = [], nfields,
113 categories = [], xField,
114 aggregate = !this.maximum,
115 maxValue = this.maximum || 0,
116 steps = this.steps, i = 0, j, dx, dy,
118 cos = Math.cos, sin = Math.sin,
119 display = this.label.display,
120 draw = display !== 'none',
127 //get all rendered fields
128 chart.series.each(function(series) {
129 fields.push(series.yField);
130 xField = series.xField;
133 //get maxValue to interpolate
134 store.each(function(record, i) {
136 for (i = 0, nfields = fields.length; i < nfields; i++) {
137 maxValue = max(+record.get(fields[i]), maxValue);
140 categories.push(record.get(xField));
142 if (!this.labelArray) {
143 if (display != 'categories') {
145 for (i = 1; i <= steps; i++) {
146 label = surface.add({
148 text: round(i / steps * maxValue),
150 y: centerY - rho * i / steps,
151 'text-anchor': 'middle',
155 label.setAttributes({
158 labelArray.push(label);
161 if (display != 'scale') {
163 for (j = 0, steps = categories.length; j < steps; j++) {
164 dx = cos(j / steps * pi2) * (rho + margin);
165 dy = sin(j / steps * pi2) * (rho + margin);
166 label = surface.add({
171 'text-anchor': dx * dx <= 0.001? 'middle' : (dx < 0? 'end' : 'start')
173 label.setAttributes({
176 labelArray.push(label);
181 labelArray = this.labelArray;
182 if (display != 'categories') {
184 for (i = 0; i < steps; i++) {
185 labelArray[i].setAttributes({
186 text: round((i + 1) / steps * maxValue),
188 y: centerY - rho * (i + 1) / steps,
189 'text-anchor': 'middle',
195 if (display != 'scale') {
197 for (j = 0, steps = categories.length; j < steps; j++) {
198 dx = cos(j / steps * pi2) * (rho + margin);
199 dy = sin(j / steps * pi2) * (rho + margin);
200 if (labelArray[i + j]) {
201 labelArray[i + j].setAttributes({
206 'text-anchor': dx * dx <= 0.001? 'middle' : (dx < 0? 'end' : 'start')
212 this.labelArray = labelArray;