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