]> git.proxmox.com Git - extjs.git/blob - extjs/packages/charts/src/chart/series/Polar.js
bump version to 7.0.0-4
[extjs.git] / extjs / packages / charts / src / chart / series / Polar.js
1 /**
2 * @abstract
3 * @class Ext.chart.series.Polar
4 * @extends Ext.chart.series.Series
5 *
6 * Common base class for series implementations that plot values using polar coordinates.
7 *
8 * Polar charts accept angles in radians. You can calculate radians with the following
9 * formula:
10 *
11 * radians = degrees x Π/180
12 */
13 Ext.define('Ext.chart.series.Polar', {
14
15 extend: 'Ext.chart.series.Series',
16
17 config: {
18
19 /**
20 * @cfg {Number} [rotation=0]
21 * The angle in radians at which the first polar series item should start.
22 */
23 rotation: 0,
24
25 /**
26 * @cfg {Number} radius
27 * @private
28 * Use {@link Ext.chart.series.Pie#cfg!radiusFactor radiusFactor} instead.
29 *
30 * The internally used radius of the polar series. Set to `null` will fit the
31 * polar series to the boundary.
32 */
33 radius: null,
34
35 /**
36 * @cfg {Array} center for the polar series.
37 */
38 center: [0, 0],
39
40 /**
41 * @cfg {Number} [offsetX=0]
42 * The x-offset of center of the polar series related to the center of the boundary.
43 */
44 offsetX: 0,
45
46 /**
47 * @cfg {Number} [offsetY=0]
48 * The y-offset of center of the polar series related to the center of the boundary.
49 */
50 offsetY: 0,
51
52 /**
53 * @cfg {Boolean} [showInLegend=true]
54 * Whether to add the series elements as legend items.
55 */
56 showInLegend: true,
57
58 /**
59 * @private
60 * @cfg {String} xField
61 */
62 xField: null,
63
64 /**
65 * @private
66 * @cfg {String} yField
67 */
68 yField: null,
69
70 /**
71 * @cfg {String} angleField
72 * The store record field name for the angular axes in radar charts,
73 * or the size of the slices in pie charts.
74 */
75 angleField: null,
76
77 /**
78 * @cfg {String} radiusField
79 * The store record field name for the radial axes in radar charts,
80 * or the radius of the slices in pie charts.
81 */
82 radiusField: null,
83
84 xAxis: null,
85
86 yAxis: null
87 },
88
89 directions: ['X', 'Y'],
90 fieldCategoryX: ['X'],
91 fieldCategoryY: ['Y'],
92
93 deprecatedConfigs: {
94 field: 'angleField',
95 lengthField: 'radiusField'
96 },
97
98 constructor: function(config) {
99 var me = this,
100 configurator = me.self.getConfigurator(),
101 configs = configurator.configs,
102 p;
103
104 if (config) {
105 for (p in me.deprecatedConfigs) {
106 if (p in config && !(config in configs)) {
107 Ext.raise("'" + p + "' config has been deprecated. Please use the '" +
108 me.deprecatedConfigs[p] + "' config instead.");
109 }
110 }
111 }
112
113 me.callParent([config]);
114 },
115
116 getXField: function() {
117 return this.getAngleField();
118 },
119
120 updateXField: function(value) {
121 this.setAngleField(value);
122 },
123
124 getYField: function() {
125 return this.getRadiusField();
126 },
127
128 updateYField: function(value) {
129 this.setRadiusField(value);
130 },
131
132 applyXAxis: function(newAxis, oldAxis) {
133 return this.getChart().getAxis(newAxis) || oldAxis;
134 },
135
136 applyYAxis: function(newAxis, oldAxis) {
137 return this.getChart().getAxis(newAxis) || oldAxis;
138 },
139
140 getXRange: function() {
141 return [this.dataRange[0], this.dataRange[2]];
142 },
143
144 getYRange: function() {
145 return [this.dataRange[1], this.dataRange[3]];
146 },
147
148 themeColorCount: function() {
149 var me = this,
150 store = me.getStore(),
151 count = store && store.getCount() || 0;
152
153 return count;
154 },
155
156 isStoreDependantColorCount: true,
157
158 getDefaultSpriteConfig: function() {
159 return {
160 type: this.seriesType,
161 renderer: this.getRenderer(),
162 centerX: 0,
163 centerY: 0,
164 rotationCenterX: 0,
165 rotationCenterY: 0
166 };
167 },
168
169 applyRotation: function(rotation) {
170 return Ext.draw.sprite.AttributeParser.angle(Ext.draw.Draw.rad(rotation));
171 },
172
173 updateRotation: function(rotation) {
174 var sprites = this.getSprites();
175
176 if (sprites && sprites[0]) {
177 sprites[0].setAttributes({
178 baseRotation: rotation
179 });
180 }
181 }
182 });