2 * @class Ext.chart.axis.Radial
3 * @extends Ext.chart.axis.Abstract
6 Ext.define('Ext.chart.axis.Radial', {
8 /* Begin Definitions */
10 extend: 'Ext.chart.axis.Abstract',
18 drawAxis: function(init) {
19 var chart = this.chart,
20 surface = chart.surface,
21 bbox = chart.chartBBox,
24 centerX = bbox.x + (bbox.width / 2),
25 centerY = bbox.y + (bbox.height / 2),
26 rho = Math.min(bbox.width, bbox.height) /2,
29 i, j, pi2 = Math.PI * 2,
30 cos = Math.cos, sin = Math.sin;
32 if (this.sprites && !chart.resizing) {
39 for (i = 1; i <= steps; i++) {
40 sprite = surface.add({
44 radius: Math.max(rho * i / steps, 0),
47 sprite.setAttributes({
53 store.each(function(rec, i) {
54 sprite = surface.add({
56 path: ['M', centerX, centerY, 'L', centerX + rho * cos(i / l * pi2), centerY + rho * sin(i / l * pi2), 'Z'],
59 sprite.setAttributes({
65 sprites = this.sprites;
67 for (i = 0; i < steps; i++) {
68 sprites[i].setAttributes({
71 radius: Math.max(rho * (i + 1) / steps, 0),
76 store.each(function(rec, j) {
77 sprites[i + j].setAttributes({
78 path: ['M', centerX, centerY, 'L', centerX + rho * cos(j / l * pi2), centerY + rho * sin(j / l * pi2), 'Z'],
83 this.sprites = sprites;
88 drawLabel: function() {
89 var chart = this.chart,
90 surface = chart.surface,
91 bbox = chart.chartBBox,
93 centerX = bbox.x + (bbox.width / 2),
94 centerY = bbox.y + (bbox.height / 2),
95 rho = Math.min(bbox.width, bbox.height) /2,
96 max = Math.max, round = Math.round,
97 labelArray = [], label,
99 categories = [], xField,
100 aggregate = !this.maximum,
101 maxValue = this.maximum || 0,
102 steps = this.steps, i = 0, j, dx, dy,
104 cos = Math.cos, sin = Math.sin,
105 display = this.label.display,
106 draw = display !== 'none',
113 //get all rendered fields
114 chart.series.each(function(series) {
115 fields.push(series.yField);
116 xField = series.xField;
119 //get maxValue to interpolate
120 store.each(function(record, i) {
122 for (i = 0, nfields = fields.length; i < nfields; i++) {
123 maxValue = max(+record.get(fields[i]), maxValue);
126 categories.push(record.get(xField));
128 if (!this.labelArray) {
129 if (display != 'categories') {
131 for (i = 1; i <= steps; i++) {
132 label = surface.add({
134 text: round(i / steps * maxValue),
136 y: centerY - rho * i / steps,
137 'text-anchor': 'middle',
141 label.setAttributes({
144 labelArray.push(label);
147 if (display != 'scale') {
149 for (j = 0, steps = categories.length; j < steps; j++) {
150 dx = cos(j / steps * pi2) * (rho + margin);
151 dy = sin(j / steps * pi2) * (rho + margin);
152 label = surface.add({
157 'text-anchor': dx * dx <= 0.001? 'middle' : (dx < 0? 'end' : 'start')
159 label.setAttributes({
162 labelArray.push(label);
167 labelArray = this.labelArray;
168 if (display != 'categories') {
170 for (i = 0; i < steps; i++) {
171 labelArray[i].setAttributes({
172 text: round((i + 1) / steps * maxValue),
174 y: centerY - rho * (i + 1) / steps,
175 'text-anchor': 'middle',
181 if (display != 'scale') {
183 for (j = 0, steps = categories.length; j < steps; j++) {
184 dx = cos(j / steps * pi2) * (rho + margin);
185 dy = sin(j / steps * pi2) * (rho + margin);
186 if (labelArray[i + j]) {
187 labelArray[i + j].setAttributes({
192 'text-anchor': dx * dx <= 0.001? 'middle' : (dx < 0? 'end' : 'start')
198 this.labelArray = labelArray;