4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5 <title>The source code</title>
6 <link href="../prettify/prettify.css" type="text/css" rel="stylesheet" />
7 <script type="text/javascript" src="../prettify/prettify.js"></script>
8 <style type="text/css">
9 .highlight { display: block; background-color: #ddd; }
11 <script type="text/javascript">
12 function highlight() {
13 document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
17 <body onload="prettyPrint(); highlight();">
18 <pre class="prettyprint lang-js"><span id='Ext-chart-axis-Radial'>/**
19 </span> * @class Ext.chart.axis.Radial
20 * @extends Ext.chart.axis.Abstract
23 Ext.define('Ext.chart.axis.Radial', {
25 /* Begin Definitions */
27 extend: 'Ext.chart.axis.Abstract',
35 drawAxis: function(init) {
36 var chart = this.chart,
37 surface = chart.surface,
38 bbox = chart.chartBBox,
41 centerX = bbox.x + (bbox.width / 2),
42 centerY = bbox.y + (bbox.height / 2),
43 rho = Math.min(bbox.width, bbox.height) /2,
46 i, j, pi2 = Math.PI * 2,
47 cos = Math.cos, sin = Math.sin;
49 if (this.sprites && !chart.resizing) {
56 for (i = 1; i <= steps; i++) {
57 sprite = surface.add({
61 radius: Math.max(rho * i / steps, 0),
64 sprite.setAttributes({
70 store.each(function(rec, i) {
71 sprite = surface.add({
73 path: ['M', centerX, centerY, 'L', centerX + rho * cos(i / l * pi2), centerY + rho * sin(i / l * pi2), 'Z'],
76 sprite.setAttributes({
82 sprites = this.sprites;
84 for (i = 0; i < steps; i++) {
85 sprites[i].setAttributes({
88 radius: Math.max(rho * (i + 1) / steps, 0),
93 store.each(function(rec, j) {
94 sprites[i + j].setAttributes({
95 path: ['M', centerX, centerY, 'L', centerX + rho * cos(j / l * pi2), centerY + rho * sin(j / l * pi2), 'Z'],
100 this.sprites = sprites;
105 drawLabel: function() {
106 var chart = this.chart,
107 surface = chart.surface,
108 bbox = chart.chartBBox,
110 centerX = bbox.x + (bbox.width / 2),
111 centerY = bbox.y + (bbox.height / 2),
112 rho = Math.min(bbox.width, bbox.height) /2,
113 max = Math.max, round = Math.round,
114 labelArray = [], label,
115 fields = [], nfields,
116 categories = [], xField,
117 aggregate = !this.maximum,
118 maxValue = this.maximum || 0,
119 steps = this.steps, i = 0, j, dx, dy,
121 cos = Math.cos, sin = Math.sin,
122 display = this.label.display,
123 draw = display !== 'none',
130 //get all rendered fields
131 chart.series.each(function(series) {
132 fields.push(series.yField);
133 xField = series.xField;
136 //get maxValue to interpolate
137 store.each(function(record, i) {
139 for (i = 0, nfields = fields.length; i < nfields; i++) {
140 maxValue = max(+record.get(fields[i]), maxValue);
143 categories.push(record.get(xField));
145 if (!this.labelArray) {
146 if (display != 'categories') {
148 for (i = 1; i <= steps; i++) {
149 label = surface.add({
151 text: round(i / steps * maxValue),
153 y: centerY - rho * i / steps,
154 'text-anchor': 'middle',
158 label.setAttributes({
161 labelArray.push(label);
164 if (display != 'scale') {
166 for (j = 0, steps = categories.length; j < steps; j++) {
167 dx = cos(j / steps * pi2) * (rho + margin);
168 dy = sin(j / steps * pi2) * (rho + margin);
169 label = surface.add({
174 'text-anchor': dx * dx <= 0.001? 'middle' : (dx < 0? 'end' : 'start')
176 label.setAttributes({
179 labelArray.push(label);
184 labelArray = this.labelArray;
185 if (display != 'categories') {
187 for (i = 0; i < steps; i++) {
188 labelArray[i].setAttributes({
189 text: round((i + 1) / steps * maxValue),
191 y: centerY - rho * (i + 1) / steps,
192 'text-anchor': 'middle',
198 if (display != 'scale') {
200 for (j = 0, steps = categories.length; j < steps; j++) {
201 dx = cos(j / steps * pi2) * (rho + margin);
202 dy = sin(j / steps * pi2) * (rho + margin);
203 if (labelArray[i + j]) {
204 labelArray[i + j].setAttributes({
209 'text-anchor': dx * dx <= 0.001? 'middle' : (dx < 0? 'end' : 'start')
215 this.labelArray = labelArray;