|
525
|
1 |
/* |
|
|
2 |
YUI 3.10.3 (build 2fb5187) |
|
|
3 |
Copyright 2013 Yahoo! Inc. All rights reserved. |
|
|
4 |
Licensed under the BSD License. |
|
|
5 |
http://yuilibrary.com/license/ |
|
|
6 |
*/ |
|
|
7 |
|
|
|
8 |
YUI.add('axis-base', function (Y, NAME) { |
|
|
9 |
|
|
|
10 |
/** |
|
|
11 |
* The Charts widget provides an api for displaying data |
|
|
12 |
* graphically. |
|
|
13 |
* |
|
|
14 |
* @module charts |
|
|
15 |
* @main charts |
|
|
16 |
*/ |
|
|
17 |
|
|
|
18 |
/** |
|
|
19 |
* Provides functionality for the handling of axis data in a chart. |
|
|
20 |
* |
|
|
21 |
* @module charts |
|
|
22 |
* @submodule axis-base |
|
|
23 |
*/ |
|
|
24 |
var Y_Lang = Y.Lang; |
|
|
25 |
|
|
|
26 |
/** |
|
|
27 |
* The Renderer class is a base class for chart components that use the `styles` |
|
|
28 |
* attribute. |
|
|
29 |
* |
|
|
30 |
* @module charts |
|
|
31 |
* @class Renderer |
|
|
32 |
* @constructor |
|
|
33 |
*/ |
|
|
34 |
function Renderer(){} |
|
|
35 |
|
|
|
36 |
Renderer.ATTRS = { |
|
|
37 |
/** |
|
|
38 |
* Style properties for class |
|
|
39 |
* |
|
|
40 |
* @attribute styles |
|
|
41 |
* @type Object |
|
|
42 |
*/ |
|
|
43 |
styles: |
|
|
44 |
{ |
|
|
45 |
getter: function() |
|
|
46 |
{ |
|
|
47 |
this._styles = this._styles || this._getDefaultStyles(); |
|
|
48 |
return this._styles; |
|
|
49 |
}, |
|
|
50 |
|
|
|
51 |
setter: function(val) |
|
|
52 |
{ |
|
|
53 |
this._styles = this._setStyles(val); |
|
|
54 |
} |
|
|
55 |
}, |
|
|
56 |
|
|
|
57 |
/** |
|
|
58 |
* The graphic in which drawings will be rendered. |
|
|
59 |
* |
|
|
60 |
* @attribute graphic |
|
|
61 |
* @type Graphic |
|
|
62 |
*/ |
|
|
63 |
graphic: {} |
|
|
64 |
}; |
|
|
65 |
Renderer.NAME = "renderer"; |
|
|
66 |
|
|
|
67 |
Renderer.prototype = { |
|
|
68 |
/** |
|
|
69 |
* Storage for `styles` attribute. |
|
|
70 |
* |
|
|
71 |
* @property _styles |
|
|
72 |
* @type Object |
|
|
73 |
* @private |
|
|
74 |
*/ |
|
|
75 |
_styles: null, |
|
|
76 |
|
|
|
77 |
/** |
|
|
78 |
* Method used by `styles` setter. |
|
|
79 |
* |
|
|
80 |
* @method _setStyles |
|
|
81 |
* @param {Object} newStyles Hash of properties to update. |
|
|
82 |
* @return Object |
|
|
83 |
* @protected |
|
|
84 |
*/ |
|
|
85 |
_setStyles: function(newstyles) |
|
|
86 |
{ |
|
|
87 |
var styles = this.get("styles"); |
|
|
88 |
return this._mergeStyles(newstyles, styles); |
|
|
89 |
}, |
|
|
90 |
|
|
|
91 |
/** |
|
|
92 |
* Merges to object literals so that only specified properties are |
|
|
93 |
* overwritten. |
|
|
94 |
* |
|
|
95 |
* @method _mergeStyles |
|
|
96 |
* @param {Object} a Hash of new styles |
|
|
97 |
* @param {Object} b Hash of original styles |
|
|
98 |
* @return Object |
|
|
99 |
* @protected |
|
|
100 |
*/ |
|
|
101 |
_mergeStyles: function(a, b) |
|
|
102 |
{ |
|
|
103 |
if(!b) |
|
|
104 |
{ |
|
|
105 |
b = {}; |
|
|
106 |
} |
|
|
107 |
var newstyles = Y.merge(b, {}); |
|
|
108 |
Y.Object.each(a, function(value, key) |
|
|
109 |
{ |
|
|
110 |
if(b.hasOwnProperty(key) && Y_Lang.isObject(value) && !Y_Lang.isFunction(value) && !Y_Lang.isArray(value)) |
|
|
111 |
{ |
|
|
112 |
newstyles[key] = this._mergeStyles(value, b[key]); |
|
|
113 |
} |
|
|
114 |
else |
|
|
115 |
{ |
|
|
116 |
newstyles[key] = value; |
|
|
117 |
} |
|
|
118 |
}, this); |
|
|
119 |
return newstyles; |
|
|
120 |
}, |
|
|
121 |
|
|
|
122 |
/** |
|
|
123 |
* Gets the default value for the `styles` attribute. |
|
|
124 |
* |
|
|
125 |
* @method _getDefaultStyles |
|
|
126 |
* @return Object |
|
|
127 |
* @protected |
|
|
128 |
*/ |
|
|
129 |
_getDefaultStyles: function() |
|
|
130 |
{ |
|
|
131 |
return {padding:{ |
|
|
132 |
top:0, |
|
|
133 |
right: 0, |
|
|
134 |
bottom: 0, |
|
|
135 |
left: 0 |
|
|
136 |
}}; |
|
|
137 |
} |
|
|
138 |
}; |
|
|
139 |
|
|
|
140 |
Y.augment(Renderer, Y.Attribute); |
|
|
141 |
Y.Renderer = Renderer; |
|
|
142 |
|
|
|
143 |
/** |
|
|
144 |
* The axis-base submodule contains functionality for the handling of axis data in a chart. |
|
|
145 |
* |
|
|
146 |
* @module charts |
|
|
147 |
* @submodule axis-base |
|
|
148 |
*/ |
|
|
149 |
/** |
|
|
150 |
* An abstract class that provides the core functionality used by the following classes: |
|
|
151 |
* <ul> |
|
|
152 |
* <li>{{#crossLink "CategoryAxisBase"}}{{/crossLink}}</li> |
|
|
153 |
* <li>{{#crossLink "NumericAxisBase"}}{{/crossLink}}</li> |
|
|
154 |
* <li>{{#crossLink "StackedAxisBase"}}{{/crossLink}}</li> |
|
|
155 |
* <li>{{#crossLink "TimeAxisBase"}}{{/crossLink}}</li> |
|
|
156 |
* <li>{{#crossLink "CategoryAxis"}}{{/crossLink}}</li> |
|
|
157 |
* <li>{{#crossLink "NumericAxis"}}{{/crossLink}}</li> |
|
|
158 |
* <li>{{#crossLink "StackedAxis"}}{{/crossLink}}</li> |
|
|
159 |
* <li>{{#crossLink "TimeAxis"}}{{/crossLink}}</li> |
|
|
160 |
* </ul> |
|
|
161 |
* |
|
|
162 |
* @class AxisBase |
|
|
163 |
* @constructor |
|
|
164 |
* @extends Base |
|
|
165 |
* @uses Renderer |
|
|
166 |
* @param {Object} config (optional) Configuration parameters. |
|
|
167 |
* @submodule axis-base |
|
|
168 |
*/ |
|
|
169 |
Y.AxisBase = Y.Base.create("axisBase", Y.Base, [Y.Renderer], { |
|
|
170 |
/** |
|
|
171 |
* @method initializer |
|
|
172 |
* @private |
|
|
173 |
*/ |
|
|
174 |
initializer: function() |
|
|
175 |
{ |
|
|
176 |
this.after("minimumChange", Y.bind(this._keyChangeHandler, this)); |
|
|
177 |
this.after("maximumChange", Y.bind(this._keyChangeHandler, this)); |
|
|
178 |
this.after("keysChange", this._keyChangeHandler); |
|
|
179 |
this.after("dataProviderChange", this._dataProviderChangeHandler); |
|
|
180 |
}, |
|
|
181 |
|
|
|
182 |
/** |
|
|
183 |
* Handles changes to `dataProvider`. |
|
|
184 |
* |
|
|
185 |
* @method _dataProviderChangeHandler |
|
|
186 |
* @param {Object} e Event object. |
|
|
187 |
* @private |
|
|
188 |
*/ |
|
|
189 |
_dataProviderChangeHandler: function() |
|
|
190 |
{ |
|
|
191 |
var keyCollection = this.get("keyCollection").concat(), |
|
|
192 |
keys = this.get("keys"), |
|
|
193 |
i; |
|
|
194 |
if(keys) |
|
|
195 |
{ |
|
|
196 |
for(i in keys) |
|
|
197 |
{ |
|
|
198 |
if(keys.hasOwnProperty(i)) |
|
|
199 |
{ |
|
|
200 |
delete keys[i]; |
|
|
201 |
} |
|
|
202 |
} |
|
|
203 |
} |
|
|
204 |
if(keyCollection && keyCollection.length) |
|
|
205 |
{ |
|
|
206 |
this.set("keys", keyCollection); |
|
|
207 |
} |
|
|
208 |
}, |
|
|
209 |
|
|
|
210 |
/** |
|
|
211 |
* Calculates the maximum and minimum values for the `Data`. |
|
|
212 |
* |
|
|
213 |
* @method _updateMinAndMax |
|
|
214 |
* @private |
|
|
215 |
*/ |
|
|
216 |
_updateMinAndMax: function() { |
|
|
217 |
}, |
|
|
218 |
|
|
|
219 |
/** |
|
|
220 |
* Constant used to generate unique id. |
|
|
221 |
* |
|
|
222 |
* @property GUID |
|
|
223 |
* @type String |
|
|
224 |
* @private |
|
|
225 |
*/ |
|
|
226 |
GUID: "yuibaseaxis", |
|
|
227 |
|
|
|
228 |
/** |
|
|
229 |
* Type of data used in `Axis`. |
|
|
230 |
* |
|
|
231 |
* @property _type |
|
|
232 |
* @type String |
|
|
233 |
* @readOnly |
|
|
234 |
* @private |
|
|
235 |
*/ |
|
|
236 |
_type: null, |
|
|
237 |
|
|
|
238 |
/** |
|
|
239 |
* Storage for `setMaximum` attribute. |
|
|
240 |
* |
|
|
241 |
* @property _setMaximum |
|
|
242 |
* @type Object |
|
|
243 |
* @private |
|
|
244 |
*/ |
|
|
245 |
_setMaximum: null, |
|
|
246 |
|
|
|
247 |
/** |
|
|
248 |
* Storage for `setMinimum` attribute. |
|
|
249 |
* |
|
|
250 |
* @property _setMinimum |
|
|
251 |
* @type Object |
|
|
252 |
* @private |
|
|
253 |
*/ |
|
|
254 |
_setMinimum: null, |
|
|
255 |
|
|
|
256 |
/** |
|
|
257 |
* Reference to data array. |
|
|
258 |
* |
|
|
259 |
* @property _data |
|
|
260 |
* @type Array |
|
|
261 |
* @private |
|
|
262 |
*/ |
|
|
263 |
_data: null, |
|
|
264 |
|
|
|
265 |
/** |
|
|
266 |
* Indicates whether the all data is up to date. |
|
|
267 |
* |
|
|
268 |
* @property _updateTotalDataFlag |
|
|
269 |
* @type Boolean |
|
|
270 |
* @private |
|
|
271 |
*/ |
|
|
272 |
_updateTotalDataFlag: true, |
|
|
273 |
|
|
|
274 |
/** |
|
|
275 |
* Storage for `dataReady` attribute. |
|
|
276 |
* |
|
|
277 |
* @property _dataReady |
|
|
278 |
* @type Boolean |
|
|
279 |
* @readOnly |
|
|
280 |
* @private |
|
|
281 |
*/ |
|
|
282 |
_dataReady: false, |
|
|
283 |
|
|
|
284 |
/** |
|
|
285 |
* Adds an array to the key hash. |
|
|
286 |
* |
|
|
287 |
* @method addKey |
|
|
288 |
* @param value Indicates what key to use in retrieving |
|
|
289 |
* the array. |
|
|
290 |
*/ |
|
|
291 |
addKey: function (value) |
|
|
292 |
{ |
|
|
293 |
this.set("keys", value); |
|
|
294 |
}, |
|
|
295 |
|
|
|
296 |
/** |
|
|
297 |
* Gets an array of values based on a key. |
|
|
298 |
* |
|
|
299 |
* @method _getKeyArray |
|
|
300 |
* @param {String} key Value key associated with the data array. |
|
|
301 |
* @param {Array} data Array in which the data resides. |
|
|
302 |
* @return Array |
|
|
303 |
* @private |
|
|
304 |
*/ |
|
|
305 |
_getKeyArray: function(key, data) |
|
|
306 |
{ |
|
|
307 |
var i = 0, |
|
|
308 |
obj, |
|
|
309 |
keyArray = [], |
|
|
310 |
len = data.length; |
|
|
311 |
for(; i < len; ++i) |
|
|
312 |
{ |
|
|
313 |
obj = data[i]; |
|
|
314 |
keyArray[i] = obj[key]; |
|
|
315 |
} |
|
|
316 |
return keyArray; |
|
|
317 |
}, |
|
|
318 |
|
|
|
319 |
/** |
|
|
320 |
* Updates the total data array. |
|
|
321 |
* |
|
|
322 |
* @method _updateTotalData |
|
|
323 |
* @private |
|
|
324 |
*/ |
|
|
325 |
_updateTotalData: function() |
|
|
326 |
{ |
|
|
327 |
var keys = this.get("keys"), |
|
|
328 |
i; |
|
|
329 |
this._data = []; |
|
|
330 |
for(i in keys) |
|
|
331 |
{ |
|
|
332 |
if(keys.hasOwnProperty(i)) |
|
|
333 |
{ |
|
|
334 |
this._data = this._data.concat(keys[i]); |
|
|
335 |
} |
|
|
336 |
} |
|
|
337 |
this._updateTotalDataFlag = false; |
|
|
338 |
}, |
|
|
339 |
|
|
|
340 |
/** |
|
|
341 |
* Removes an array from the key hash. |
|
|
342 |
* |
|
|
343 |
* @method removeKey |
|
|
344 |
* @param {String} value Indicates what key to use in removing from |
|
|
345 |
* the hash. |
|
|
346 |
*/ |
|
|
347 |
removeKey: function(value) |
|
|
348 |
{ |
|
|
349 |
var keys = this.get("keys"); |
|
|
350 |
if(keys.hasOwnProperty(value)) |
|
|
351 |
{ |
|
|
352 |
delete keys[value]; |
|
|
353 |
this._keyChangeHandler(); |
|
|
354 |
} |
|
|
355 |
}, |
|
|
356 |
|
|
|
357 |
/** |
|
|
358 |
* Returns a value based of a key value and an index. |
|
|
359 |
* |
|
|
360 |
* @method getKeyValueAt |
|
|
361 |
* @param {String} key value used to look up the correct array |
|
|
362 |
* @param {Number} index within the array |
|
|
363 |
* @return Number |
|
|
364 |
*/ |
|
|
365 |
getKeyValueAt: function(key, index) |
|
|
366 |
{ |
|
|
367 |
var value = NaN, |
|
|
368 |
keys = this.get("keys"); |
|
|
369 |
if(keys[key] && Y_Lang.isNumber(parseFloat(keys[key][index]))) |
|
|
370 |
{ |
|
|
371 |
value = keys[key][index]; |
|
|
372 |
} |
|
|
373 |
return parseFloat(value); |
|
|
374 |
}, |
|
|
375 |
|
|
|
376 |
/** |
|
|
377 |
* Returns values based on key identifiers. When a string is passed as an argument, an array of values is returned. |
|
|
378 |
* When an array of keys is passed as an argument, an object literal with an array of values mapped to each key is |
|
|
379 |
* returned. |
|
|
380 |
* |
|
|
381 |
* @method getDataByKey |
|
|
382 |
* @param {String|Array} value value used to identify the array |
|
|
383 |
* @return Array|Object |
|
|
384 |
*/ |
|
|
385 |
getDataByKey: function (value) |
|
|
386 |
{ |
|
|
387 |
var obj, |
|
|
388 |
i, |
|
|
389 |
len, |
|
|
390 |
key, |
|
|
391 |
keys = this.get("keys"); |
|
|
392 |
if(Y_Lang.isArray(value)) |
|
|
393 |
{ |
|
|
394 |
obj = {}; |
|
|
395 |
len = value.length; |
|
|
396 |
for(i = 0; i < len; i = i + 1) |
|
|
397 |
{ |
|
|
398 |
key = value[i]; |
|
|
399 |
if(keys[key]) |
|
|
400 |
{ |
|
|
401 |
obj[key] = this.getDataByKey(key); |
|
|
402 |
} |
|
|
403 |
} |
|
|
404 |
} |
|
|
405 |
else if(keys[value]) |
|
|
406 |
{ |
|
|
407 |
obj = keys[value]; |
|
|
408 |
} |
|
|
409 |
else |
|
|
410 |
{ |
|
|
411 |
obj = null; |
|
|
412 |
} |
|
|
413 |
return obj; |
|
|
414 |
}, |
|
|
415 |
|
|
|
416 |
/** |
|
|
417 |
* Returns the total number of majorUnits that will appear on an axis. |
|
|
418 |
* |
|
|
419 |
* @method getTotalMajorUnits |
|
|
420 |
* @return Number |
|
|
421 |
*/ |
|
|
422 |
getTotalMajorUnits: function() |
|
|
423 |
{ |
|
|
424 |
var units, |
|
|
425 |
majorUnit = this.get("styles").majorUnit; |
|
|
426 |
units = majorUnit.count; |
|
|
427 |
return units; |
|
|
428 |
}, |
|
|
429 |
|
|
|
430 |
/** |
|
|
431 |
* Gets the distance that the first and last ticks are offset from there respective |
|
|
432 |
* edges. |
|
|
433 |
* |
|
|
434 |
* @method getEdgeOffset |
|
|
435 |
* @param {Number} ct Number of ticks on the axis. |
|
|
436 |
* @param {Number} l Length (in pixels) of the axis. |
|
|
437 |
* @return Number |
|
|
438 |
*/ |
|
|
439 |
getEdgeOffset: function(ct, l) |
|
|
440 |
{ |
|
|
441 |
var edgeOffset; |
|
|
442 |
if(this.get("calculateEdgeOffset")) { |
|
|
443 |
edgeOffset = (l/ct)/2; |
|
|
444 |
} else { |
|
|
445 |
edgeOffset = 0; |
|
|
446 |
} |
|
|
447 |
return edgeOffset; |
|
|
448 |
}, |
|
|
449 |
|
|
|
450 |
/** |
|
|
451 |
* Updates the `Axis` after a change in keys. |
|
|
452 |
* |
|
|
453 |
* @method _keyChangeHandler |
|
|
454 |
* @param {Object} e Event object. |
|
|
455 |
* @private |
|
|
456 |
*/ |
|
|
457 |
_keyChangeHandler: function() |
|
|
458 |
{ |
|
|
459 |
this._updateMinAndMax(); |
|
|
460 |
this._updateTotalDataFlag = true; |
|
|
461 |
this.fire("dataUpdate"); |
|
|
462 |
}, |
|
|
463 |
|
|
|
464 |
/** |
|
|
465 |
* Gets the default value for the `styles` attribute. Overrides |
|
|
466 |
* base implementation. |
|
|
467 |
* |
|
|
468 |
* @method _getDefaultStyles |
|
|
469 |
* @return Object |
|
|
470 |
* @protected |
|
|
471 |
*/ |
|
|
472 |
_getDefaultStyles: function() |
|
|
473 |
{ |
|
|
474 |
var axisstyles = { |
|
|
475 |
majorUnit: { |
|
|
476 |
determinant:"count", |
|
|
477 |
count:11, |
|
|
478 |
distance:75 |
|
|
479 |
} |
|
|
480 |
}; |
|
|
481 |
return axisstyles; |
|
|
482 |
}, |
|
|
483 |
|
|
|
484 |
/** |
|
|
485 |
* Getter method for maximum attribute. |
|
|
486 |
* |
|
|
487 |
* @method _maximumGetter |
|
|
488 |
* @return Number |
|
|
489 |
* @private |
|
|
490 |
*/ |
|
|
491 |
_maximumGetter: function () |
|
|
492 |
{ |
|
|
493 |
var max = this.get("dataMaximum"), |
|
|
494 |
min = this.get("minimum"); |
|
|
495 |
//If all values are zero, force a range so that the Axis and related series |
|
|
496 |
//will still render. |
|
|
497 |
if(min === 0 && max === 0) |
|
|
498 |
{ |
|
|
499 |
max = 10; |
|
|
500 |
} |
|
|
501 |
if(Y_Lang.isNumber(this._setMaximum)) |
|
|
502 |
{ |
|
|
503 |
max = this._setMaximum; |
|
|
504 |
} |
|
|
505 |
return parseFloat(max); |
|
|
506 |
}, |
|
|
507 |
|
|
|
508 |
/** |
|
|
509 |
* Setter method for maximum attribute. |
|
|
510 |
* |
|
|
511 |
* @method _maximumSetter |
|
|
512 |
* @param {Object} value |
|
|
513 |
* @private |
|
|
514 |
*/ |
|
|
515 |
_maximumSetter: function (value) |
|
|
516 |
{ |
|
|
517 |
this._setMaximum = parseFloat(value); |
|
|
518 |
return value; |
|
|
519 |
}, |
|
|
520 |
|
|
|
521 |
/** |
|
|
522 |
* Getter method for minimum attribute. |
|
|
523 |
* |
|
|
524 |
* @method _minimumGetter |
|
|
525 |
* @return Number |
|
|
526 |
* @private |
|
|
527 |
*/ |
|
|
528 |
_minimumGetter: function () |
|
|
529 |
{ |
|
|
530 |
var min = this.get("dataMinimum"); |
|
|
531 |
if(Y_Lang.isNumber(this._setMinimum)) |
|
|
532 |
{ |
|
|
533 |
min = this._setMinimum; |
|
|
534 |
} |
|
|
535 |
return parseFloat(min); |
|
|
536 |
}, |
|
|
537 |
|
|
|
538 |
/** |
|
|
539 |
* Setter method for minimum attribute. |
|
|
540 |
* |
|
|
541 |
* @method _minimumSetter |
|
|
542 |
* @param {Object} value |
|
|
543 |
* @private |
|
|
544 |
*/ |
|
|
545 |
_minimumSetter: function(val) |
|
|
546 |
{ |
|
|
547 |
this._setMinimum = parseFloat(val); |
|
|
548 |
return val; |
|
|
549 |
}, |
|
|
550 |
|
|
|
551 |
/** |
|
|
552 |
* Indicates whether or not the maximum attribute has been explicitly set. |
|
|
553 |
* |
|
|
554 |
* @method _getSetMax |
|
|
555 |
* @return Boolean |
|
|
556 |
* @private |
|
|
557 |
*/ |
|
|
558 |
_getSetMax: function() |
|
|
559 |
{ |
|
|
560 |
return Y_Lang.isNumber(this._setMaximum); |
|
|
561 |
}, |
|
|
562 |
|
|
|
563 |
/** |
|
|
564 |
* Indicates whether or not the minimum attribute has been explicitly set. |
|
|
565 |
* |
|
|
566 |
* @method _getSetMin |
|
|
567 |
* @return Boolean |
|
|
568 |
* @private |
|
|
569 |
*/ |
|
|
570 |
_getSetMin: function() |
|
|
571 |
{ |
|
|
572 |
return Y_Lang.isNumber(this._setMinimum); |
|
|
573 |
} |
|
|
574 |
}, { |
|
|
575 |
ATTRS: { |
|
|
576 |
/** |
|
|
577 |
* Determines whether and offset is automatically calculated for the edges of the axis. |
|
|
578 |
* |
|
|
579 |
* @attribute calculateEdgeOffset |
|
|
580 |
* @type Boolean |
|
|
581 |
*/ |
|
|
582 |
calculateEdgeOffset: { |
|
|
583 |
value: false |
|
|
584 |
}, |
|
|
585 |
|
|
|
586 |
labelFunction: { |
|
|
587 |
valueFn: function() { |
|
|
588 |
return this.formatLabel; |
|
|
589 |
} |
|
|
590 |
}, |
|
|
591 |
|
|
|
592 |
/** |
|
|
593 |
* Hash of array identifed by a string value. |
|
|
594 |
* |
|
|
595 |
* @attribute keys |
|
|
596 |
* @type Object |
|
|
597 |
*/ |
|
|
598 |
keys: { |
|
|
599 |
value: {}, |
|
|
600 |
|
|
|
601 |
setter: function(val) |
|
|
602 |
{ |
|
|
603 |
var keys = {}, |
|
|
604 |
i, |
|
|
605 |
len, |
|
|
606 |
data = this.get("dataProvider"); |
|
|
607 |
if(Y_Lang.isArray(val)) |
|
|
608 |
{ |
|
|
609 |
len = val.length; |
|
|
610 |
for(i = 0; i < len; ++i) |
|
|
611 |
{ |
|
|
612 |
keys[val[i]] = this._getKeyArray(val[i], data); |
|
|
613 |
} |
|
|
614 |
|
|
|
615 |
} |
|
|
616 |
else if(Y_Lang.isString(val)) |
|
|
617 |
{ |
|
|
618 |
keys = this.get("keys"); |
|
|
619 |
keys[val] = this._getKeyArray(val, data); |
|
|
620 |
} |
|
|
621 |
else |
|
|
622 |
{ |
|
|
623 |
for(i in val) |
|
|
624 |
{ |
|
|
625 |
if(val.hasOwnProperty(i)) |
|
|
626 |
{ |
|
|
627 |
keys[i] = this._getKeyArray(i, data); |
|
|
628 |
} |
|
|
629 |
} |
|
|
630 |
} |
|
|
631 |
this._updateTotalDataFlag = true; |
|
|
632 |
return keys; |
|
|
633 |
} |
|
|
634 |
}, |
|
|
635 |
|
|
|
636 |
/** |
|
|
637 |
*Returns the type of axis data |
|
|
638 |
* <dl> |
|
|
639 |
* <dt>time</dt><dd>Manages time data</dd> |
|
|
640 |
* <dt>stacked</dt><dd>Manages stacked numeric data</dd> |
|
|
641 |
* <dt>numeric</dt><dd>Manages numeric data</dd> |
|
|
642 |
* <dt>category</dt><dd>Manages categorical data</dd> |
|
|
643 |
* </dl> |
|
|
644 |
* |
|
|
645 |
* @attribute type |
|
|
646 |
* @type String |
|
|
647 |
*/ |
|
|
648 |
type: |
|
|
649 |
{ |
|
|
650 |
readOnly: true, |
|
|
651 |
|
|
|
652 |
getter: function () |
|
|
653 |
{ |
|
|
654 |
return this._type; |
|
|
655 |
} |
|
|
656 |
}, |
|
|
657 |
|
|
|
658 |
/** |
|
|
659 |
* Instance of `ChartDataProvider` that the class uses |
|
|
660 |
* to build its own data. |
|
|
661 |
* |
|
|
662 |
* @attribute dataProvider |
|
|
663 |
* @type Array |
|
|
664 |
*/ |
|
|
665 |
dataProvider:{ |
|
|
666 |
setter: function (value) |
|
|
667 |
{ |
|
|
668 |
return value; |
|
|
669 |
} |
|
|
670 |
}, |
|
|
671 |
|
|
|
672 |
/** |
|
|
673 |
* The maximum value contained in the `data` array. Used for |
|
|
674 |
* `maximum` when `autoMax` is true. |
|
|
675 |
* |
|
|
676 |
* @attribute dataMaximum |
|
|
677 |
* @type Number |
|
|
678 |
*/ |
|
|
679 |
dataMaximum: { |
|
|
680 |
getter: function () |
|
|
681 |
{ |
|
|
682 |
if(!Y_Lang.isNumber(this._dataMaximum)) |
|
|
683 |
{ |
|
|
684 |
this._updateMinAndMax(); |
|
|
685 |
} |
|
|
686 |
return this._dataMaximum; |
|
|
687 |
} |
|
|
688 |
}, |
|
|
689 |
|
|
|
690 |
/** |
|
|
691 |
* The maximum value that will appear on an axis. |
|
|
692 |
* |
|
|
693 |
* @attribute maximum |
|
|
694 |
* @type Number |
|
|
695 |
*/ |
|
|
696 |
maximum: { |
|
|
697 |
lazyAdd: false, |
|
|
698 |
|
|
|
699 |
getter: "_maximumGetter", |
|
|
700 |
|
|
|
701 |
setter: "_maximumSetter" |
|
|
702 |
}, |
|
|
703 |
|
|
|
704 |
/** |
|
|
705 |
* The minimum value contained in the `data` array. Used for |
|
|
706 |
* `minimum` when `autoMin` is true. |
|
|
707 |
* |
|
|
708 |
* @attribute dataMinimum |
|
|
709 |
* @type Number |
|
|
710 |
*/ |
|
|
711 |
dataMinimum: { |
|
|
712 |
getter: function () |
|
|
713 |
{ |
|
|
714 |
if(!Y_Lang.isNumber(this._dataMinimum)) |
|
|
715 |
{ |
|
|
716 |
this._updateMinAndMax(); |
|
|
717 |
} |
|
|
718 |
return this._dataMinimum; |
|
|
719 |
} |
|
|
720 |
}, |
|
|
721 |
|
|
|
722 |
/** |
|
|
723 |
* The minimum value that will appear on an axis. |
|
|
724 |
* |
|
|
725 |
* @attribute minimum |
|
|
726 |
* @type Number |
|
|
727 |
*/ |
|
|
728 |
minimum: { |
|
|
729 |
lazyAdd: false, |
|
|
730 |
|
|
|
731 |
getter: "_minimumGetter", |
|
|
732 |
|
|
|
733 |
setter: "_minimumSetter" |
|
|
734 |
}, |
|
|
735 |
|
|
|
736 |
/** |
|
|
737 |
* Determines whether the maximum is calculated or explicitly |
|
|
738 |
* set by the user. |
|
|
739 |
* |
|
|
740 |
* @attribute setMax |
|
|
741 |
* @type Boolean |
|
|
742 |
*/ |
|
|
743 |
setMax: { |
|
|
744 |
readOnly: true, |
|
|
745 |
|
|
|
746 |
getter: "_getSetMax" |
|
|
747 |
}, |
|
|
748 |
|
|
|
749 |
/** |
|
|
750 |
* Determines whether the minimum is calculated or explicitly |
|
|
751 |
* set by the user. |
|
|
752 |
* |
|
|
753 |
* @attribute setMin |
|
|
754 |
* @type Boolean |
|
|
755 |
*/ |
|
|
756 |
setMin: { |
|
|
757 |
readOnly: true, |
|
|
758 |
|
|
|
759 |
getter: "_getSetMin" |
|
|
760 |
}, |
|
|
761 |
|
|
|
762 |
/** |
|
|
763 |
* Array of axis data |
|
|
764 |
* |
|
|
765 |
* @attribute data |
|
|
766 |
* @type Array |
|
|
767 |
*/ |
|
|
768 |
data: { |
|
|
769 |
getter: function () |
|
|
770 |
{ |
|
|
771 |
if(!this._data || this._updateTotalDataFlag) |
|
|
772 |
{ |
|
|
773 |
this._updateTotalData(); |
|
|
774 |
} |
|
|
775 |
return this._data; |
|
|
776 |
} |
|
|
777 |
}, |
|
|
778 |
|
|
|
779 |
/** |
|
|
780 |
* Array containing all the keys in the axis. |
|
|
781 |
|
|
|
782 |
* @attribute keyCollection |
|
|
783 |
* @type Array |
|
|
784 |
*/ |
|
|
785 |
keyCollection: { |
|
|
786 |
getter: function() |
|
|
787 |
{ |
|
|
788 |
var keys = this.get("keys"), |
|
|
789 |
i, |
|
|
790 |
col = []; |
|
|
791 |
for(i in keys) |
|
|
792 |
{ |
|
|
793 |
if(keys.hasOwnProperty(i)) |
|
|
794 |
{ |
|
|
795 |
col.push(i); |
|
|
796 |
} |
|
|
797 |
} |
|
|
798 |
return col; |
|
|
799 |
}, |
|
|
800 |
readOnly: true |
|
|
801 |
}, |
|
|
802 |
|
|
|
803 |
/** |
|
|
804 |
* Object which should have by the labelFunction |
|
|
805 |
* |
|
|
806 |
* @attribute labelFunctionScope |
|
|
807 |
* @type Object |
|
|
808 |
*/ |
|
|
809 |
labelFunctionScope: {} |
|
|
810 |
} |
|
|
811 |
}); |
|
|
812 |
|
|
|
813 |
|
|
|
814 |
}, '3.10.3', {"requires": ["classnamemanager", "datatype-number", "datatype-date", "base", "event-custom"]}); |