forked from kirjs/react-highcharts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmore.js
21943 lines (18867 loc) · 589 KB
/
more.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory(require("react"), require("react/addons"));
else if(typeof define === 'function' && define.amd)
define(["react", "react/addons"], factory);
else if(typeof exports === 'object')
exports["Highcharts"] = factory(require("react"), require("react/addons"));
else
root["Highcharts"] = factory(root["react"], root["react/addons"]);
})(this, function(__WEBPACK_EXTERNAL_MODULE_4__, __WEBPACK_EXTERNAL_MODULE_5__) {
return /******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])
/******/ return installedModules[moduleId].exports;
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ exports: {},
/******/ id: moduleId,
/******/ loaded: false
/******/ };
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ // Flag the module as loaded
/******/ module.loaded = true;
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/ // Load entry module and return exports
/******/ return __webpack_require__(0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(1);
__webpack_require__(6);
/***/ },
/* 1 */
/***/ function(module, exports, __webpack_require__) {
/* WEBPACK VAR INJECTION */(function(global) {global.HighchartsAdapter = __webpack_require__(2);
var Highcharts = __webpack_require__(3);
var React = __webpack_require__(4);
var update = __webpack_require__(5).addons.update;
module.exports = React.createClass({
displayName: 'Highcharts',
renderChart: function () {
if (!this.props.config) {
throw new Error('Config has to be specified, for the Highchart component');
}
var config = this.props.config;
var series = this.props.series;
var node = this.refs.chart.getDOMNode();
if (!config.chart) {
config = update(config, {chart: {$set: {}}})
}
config = update(config, {series: {$set: series}, chart: {renderTo: {$set: node}}});
this.chart = new Highcharts.Chart(config);
},
updateChart: function() {
var series = this.props.series;
for (var i = 0; i < series.length; i++) {
this.chart.series[i].setData(series[i].data);
}
},
componentDidMount: function () {
this.renderChart();
},
componentDidUpdate: function () {
this.updateChart();
},
render: function () {
return React.createElement("div", {className: "chart", ref: "chart"})
}
});
module.exports.Highcharts = Highcharts;
/* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }())))
/***/ },
/* 2 */
/***/ function(module, exports, __webpack_require__) {
/**
* @license @product.name@ JS [email protected]@ (@product.date@)
*
* Standalone Highcharts Framework
*
* License: MIT License
*/
/*global Highcharts */
var HighchartsAdapter = (function () {
var UNDEFINED,
doc = document,
emptyArray = [],
timers = [],
timerId,
animSetters = {},
Fx;
Math.easeInOutSine = function (t, b, c, d) {
return -c / 2 * (Math.cos(Math.PI * t / d) - 1) + b;
};
/**
* Extend given object with custom events
*/
function augment(obj) {
function removeOneEvent(el, type, fn) {
el.removeEventListener(type, fn, false);
}
function IERemoveOneEvent(el, type, fn) {
fn = el.HCProxiedMethods[fn.toString()];
el.detachEvent('on' + type, fn);
}
function removeAllEvents(el, type) {
var events = el.HCEvents,
remove,
types,
len,
n;
if (el.removeEventListener) {
remove = removeOneEvent;
} else if (el.attachEvent) {
remove = IERemoveOneEvent;
} else {
return; // break on non-DOM events
}
if (type) {
types = {};
types[type] = true;
} else {
types = events;
}
for (n in types) {
if (events[n]) {
len = events[n].length;
while (len--) {
remove(el, n, events[n][len]);
}
}
}
}
if (!obj.HCExtended) {
Highcharts.extend(obj, {
HCExtended: true,
HCEvents: {},
bind: function (name, fn) {
var el = this,
events = this.HCEvents,
wrappedFn;
// handle DOM events in modern browsers
if (el.addEventListener) {
el.addEventListener(name, fn, false);
// handle old IE implementation
} else if (el.attachEvent) {
wrappedFn = function (e) {
e.target = e.srcElement || window; // #2820
fn.call(el, e);
};
if (!el.HCProxiedMethods) {
el.HCProxiedMethods = {};
}
// link wrapped fn with original fn, so we can get this in removeEvent
el.HCProxiedMethods[fn.toString()] = wrappedFn;
el.attachEvent('on' + name, wrappedFn);
}
if (events[name] === UNDEFINED) {
events[name] = [];
}
events[name].push(fn);
},
unbind: function (name, fn) {
var events,
index;
if (name) {
events = this.HCEvents[name] || [];
if (fn) {
index = HighchartsAdapter.inArray(fn, events);
if (index > -1) {
events.splice(index, 1);
this.HCEvents[name] = events;
}
if (this.removeEventListener) {
removeOneEvent(this, name, fn);
} else if (this.attachEvent) {
IERemoveOneEvent(this, name, fn);
}
} else {
removeAllEvents(this, name);
this.HCEvents[name] = [];
}
} else {
removeAllEvents(this);
this.HCEvents = {};
}
},
trigger: function (name, args) {
var events = this.HCEvents[name] || [],
target = this,
len = events.length,
i,
preventDefault,
fn;
// Attach a simple preventDefault function to skip default handler if called
preventDefault = function () {
args.defaultPrevented = true;
};
for (i = 0; i < len; i++) {
fn = events[i];
// args is never null here
if (args.stopped) {
return;
}
args.preventDefault = preventDefault;
args.target = target;
// If the type is not set, we're running a custom event (#2297). If it is set,
// we're running a browser event, and setting it will cause en error in
// IE8 (#2465).
if (!args.type) {
args.type = name;
}
// If the event handler return false, prevent the default handler from executing
if (fn.call(this, args) === false) {
args.preventDefault();
}
}
}
});
}
return obj;
}
return {
/**
* Initialize the adapter. This is run once as Highcharts is first run.
*/
init: function (pathAnim) {
/**
* Compatibility section to add support for legacy IE. This can be removed if old IE
* support is not needed.
*/
if (!doc.defaultView) {
this._getStyle = function (el, prop) {
var val;
if (el.style[prop]) {
return el.style[prop];
} else {
if (prop === 'opacity') {
prop = 'filter';
}
/*jslint unparam: true*/
val = el.currentStyle[prop.replace(/\-(\w)/g, function (a, b) { return b.toUpperCase(); })];
if (prop === 'filter') {
val = val.replace(
/alpha\(opacity=([0-9]+)\)/,
function (a, b) {
return b / 100;
}
);
}
/*jslint unparam: false*/
return val === '' ? 1 : val;
}
};
this.adapterRun = function (elem, method) {
var alias = { width: 'clientWidth', height: 'clientHeight' }[method];
if (alias) {
elem.style.zoom = 1;
return elem[alias] - 2 * parseInt(HighchartsAdapter._getStyle(elem, 'padding'), 10);
}
};
}
if (!Array.prototype.forEach) {
this.each = function (arr, fn) { // legacy
var i = 0,
len = arr.length;
for (; i < len; i++) {
if (fn.call(arr[i], arr[i], i, arr) === false) {
return i;
}
}
};
}
if (!Array.prototype.indexOf) {
this.inArray = function (item, arr) {
var len,
i = 0;
if (arr) {
len = arr.length;
for (; i < len; i++) {
if (arr[i] === item) {
return i;
}
}
}
return -1;
};
}
if (!Array.prototype.filter) {
this.grep = function (elements, callback) {
var ret = [],
i = 0,
length = elements.length;
for (; i < length; i++) {
if (!!callback(elements[i], i)) {
ret.push(elements[i]);
}
}
return ret;
};
}
//--- End compatibility section ---
/**
* Start of animation specific code
*/
Fx = function (elem, options, prop) {
this.options = options;
this.elem = elem;
this.prop = prop;
};
Fx.prototype = {
update: function () {
var styles,
paths = this.paths,
elem = this.elem,
elemelem = elem.element; // if destroyed, it is null
// Animation setter defined from outside
if (animSetters[this.prop]) {
animSetters[this.prop](this);
// Animating a path definition on SVGElement
} else if (paths && elemelem) {
elem.attr('d', pathAnim.step(paths[0], paths[1], this.now, this.toD));
// Other animations on SVGElement
} else if (elem.attr) {
if (elemelem) {
elem.attr(this.prop, this.now);
}
// HTML styles
} else {
styles = {};
styles[this.prop] = this.now + this.unit;
Highcharts.css(elem, styles);
}
if (this.options.step) {
this.options.step.call(this.elem, this.now, this);
}
},
custom: function (from, to, unit) {
var self = this,
t = function (gotoEnd) {
return self.step(gotoEnd);
},
i;
this.startTime = +new Date();
this.start = from;
this.end = to;
this.unit = unit;
this.now = this.start;
this.pos = this.state = 0;
t.elem = this.elem;
if (t() && timers.push(t) === 1) {
timerId = setInterval(function () {
for (i = 0; i < timers.length; i++) {
if (!timers[i]()) {
timers.splice(i--, 1);
}
}
if (!timers.length) {
clearInterval(timerId);
}
}, 13);
}
},
step: function (gotoEnd) {
var t = +new Date(),
ret,
done,
options = this.options,
elem = this.elem,
i;
if (elem.stopAnimation || (elem.attr && !elem.element)) { // #2616, element including flag is destroyed
ret = false;
} else if (gotoEnd || t >= options.duration + this.startTime) {
this.now = this.end;
this.pos = this.state = 1;
this.update();
this.options.curAnim[this.prop] = true;
done = true;
for (i in options.curAnim) {
if (options.curAnim[i] !== true) {
done = false;
}
}
if (done) {
if (options.complete) {
options.complete.call(elem);
}
}
ret = false;
} else {
var n = t - this.startTime;
this.state = n / options.duration;
this.pos = options.easing(n, 0, 1, options.duration);
this.now = this.start + ((this.end - this.start) * this.pos);
this.update();
ret = true;
}
return ret;
}
};
/**
* The adapter animate method
*/
this.animate = function (el, prop, opt) {
var start,
unit = '',
end,
fx,
args,
name;
el.stopAnimation = false; // ready for new
if (typeof opt !== 'object' || opt === null) {
args = arguments;
opt = {
duration: args[2],
easing: args[3],
complete: args[4]
};
}
if (typeof opt.duration !== 'number') {
opt.duration = 400;
}
opt.easing = Math[opt.easing] || Math.easeInOutSine;
opt.curAnim = Highcharts.extend({}, prop);
for (name in prop) {
fx = new Fx(el, opt, name);
end = null;
if (name === 'd') {
fx.paths = pathAnim.init(
el,
el.d,
prop.d
);
fx.toD = prop.d;
start = 0;
end = 1;
} else if (el.attr) {
start = el.attr(name);
} else {
start = parseFloat(HighchartsAdapter._getStyle(el, name)) || 0;
if (name !== 'opacity') {
unit = 'px';
}
}
if (!end) {
end = prop[name];
}
fx.custom(start, end, unit);
}
};
},
/**
* Internal method to return CSS value for given element and property
*/
_getStyle: function (el, prop) {
return window.getComputedStyle(el, undefined).getPropertyValue(prop);
},
/**
* Add an animation setter for a specific property
*/
addAnimSetter: function (prop, fn) {
animSetters[prop] = fn;
},
/**
* Downloads a script and executes a callback when done.
* @param {String} scriptLocation
* @param {Function} callback
*/
getScript: function (scriptLocation, callback) {
// We cannot assume that Assets class from mootools-more is available so instead insert a script tag to download script.
var head = doc.getElementsByTagName('head')[0],
script = doc.createElement('script');
script.type = 'text/javascript';
script.src = scriptLocation;
script.onload = callback;
head.appendChild(script);
},
/**
* Return the index of an item in an array, or -1 if not found
*/
inArray: function (item, arr) {
return arr.indexOf ? arr.indexOf(item) : emptyArray.indexOf.call(arr, item);
},
/**
* A direct link to adapter methods
*/
adapterRun: function (elem, method) {
return parseInt(HighchartsAdapter._getStyle(elem, method), 10);
},
/**
* Filter an array
*/
grep: function (elements, callback) {
return emptyArray.filter.call(elements, callback);
},
/**
* Map an array
*/
map: function (arr, fn) {
var results = [], i = 0, len = arr.length;
for (; i < len; i++) {
results[i] = fn.call(arr[i], arr[i], i, arr);
}
return results;
},
/**
* Get the element's offset position, corrected by overflow:auto. Loosely based on jQuery's offset method.
*/
offset: function (el) {
var docElem = document.documentElement,
box = el.getBoundingClientRect();
return {
top: box.top + (window.pageYOffset || docElem.scrollTop) - (docElem.clientTop || 0),
left: box.left + (window.pageXOffset || docElem.scrollLeft) - (docElem.clientLeft || 0)
};
},
/**
* Add an event listener
*/
addEvent: function (el, type, fn) {
augment(el).bind(type, fn);
},
/**
* Remove event added with addEvent
*/
removeEvent: function (el, type, fn) {
augment(el).unbind(type, fn);
},
/**
* Fire an event on a custom object
*/
fireEvent: function (el, type, eventArguments, defaultFunction) {
var e;
if (doc.createEvent && (el.dispatchEvent || el.fireEvent)) {
e = doc.createEvent('Events');
e.initEvent(type, true, true);
e.target = el;
Highcharts.extend(e, eventArguments);
if (el.dispatchEvent) {
el.dispatchEvent(e);
} else {
el.fireEvent(type, e);
}
} else if (el.HCExtended === true) {
eventArguments = eventArguments || {};
el.trigger(type, eventArguments);
}
if (eventArguments && eventArguments.defaultPrevented) {
defaultFunction = null;
}
if (defaultFunction) {
defaultFunction(eventArguments);
}
},
washMouseEvent: function (e) {
return e;
},
/**
* Stop running animation
*/
stop: function (el) {
el.stopAnimation = true;
},
/**
* Utility for iterating over an array. Parameters are reversed compared to jQuery.
* @param {Array} arr
* @param {Function} fn
*/
each: function (arr, fn) { // modern browsers
return Array.prototype.forEach.call(arr, fn);
}
};
}());
/*** EXPORTS FROM exports-loader ***/
module.exports = HighchartsAdapter
/***/ },
/* 3 */
/***/ function(module, exports, __webpack_require__) {
// ==ClosureCompiler==
// @compilation_level SIMPLE_OPTIMIZATIONS
/**
* @license Highcharts JS v4.1.5-modified ()
*
* (c) 2009-2014 Torstein Honsi
*
* License: www.highcharts.com/license
*/
// JSLint options:
/*global Highcharts, HighchartsAdapter, document, window, navigator, setInterval, clearInterval, clearTimeout, setTimeout, location, jQuery, $, console, each, grep */
/*jslint ass: true, sloppy: true, forin: true, plusplus: true, nomen: true, vars: true, regexp: true, newcap: true, browser: true, continue: true, white: true */
(function () {
// encapsulated variables
var UNDEFINED,
doc = document,
win = window,
math = Math,
mathRound = math.round,
mathFloor = math.floor,
mathCeil = math.ceil,
mathMax = math.max,
mathMin = math.min,
mathAbs = math.abs,
mathCos = math.cos,
mathSin = math.sin,
mathPI = math.PI,
deg2rad = mathPI * 2 / 360,
// some variables
userAgent = navigator.userAgent,
isOpera = win.opera,
isIE = /(msie|trident)/i.test(userAgent) && !isOpera,
docMode8 = doc.documentMode === 8,
isWebKit = /AppleWebKit/.test(userAgent),
isFirefox = /Firefox/.test(userAgent),
isTouchDevice = /(Mobile|Android|Windows Phone)/.test(userAgent),
SVG_NS = 'http://www.w3.org/2000/svg',
hasSVG = !!doc.createElementNS && !!doc.createElementNS(SVG_NS, 'svg').createSVGRect,
hasBidiBug = isFirefox && parseInt(userAgent.split('Firefox/')[1], 10) < 4, // issue #38
useCanVG = !hasSVG && !isIE && !!doc.createElement('canvas').getContext,
Renderer,
hasTouch,
symbolSizes = {},
idCounter = 0,
garbageBin,
defaultOptions,
dateFormat, // function
globalAnimation,
pathAnim,
timeUnits,
noop = function () { return UNDEFINED; },
charts = [],
chartCount = 0,
PRODUCT = 'Highcharts',
VERSION = '4.1.5-modified',
// some constants for frequently used strings
DIV = 'div',
ABSOLUTE = 'absolute',
RELATIVE = 'relative',
HIDDEN = 'hidden',
PREFIX = 'highcharts-',
VISIBLE = 'visible',
PX = 'px',
NONE = 'none',
M = 'M',
L = 'L',
numRegex = /^[0-9]+$/,
NORMAL_STATE = '',
HOVER_STATE = 'hover',
SELECT_STATE = 'select',
marginNames = ['plotTop', 'marginRight', 'marginBottom', 'plotLeft'],
// Object for extending Axis
AxisPlotLineOrBandExtension,
// constants for attributes
STROKE_WIDTH = 'stroke-width',
// time methods, changed based on whether or not UTC is used
Date, // Allow using a different Date class
makeTime,
timezoneOffset,
getTimezoneOffset,
getMinutes,
getHours,
getDay,
getDate,
getMonth,
getFullYear,
setMilliseconds,
setSeconds,
setMinutes,
setHours,
setDate,
setMonth,
setFullYear,
// lookup over the types and the associated classes
seriesTypes = {},
Highcharts;
// The Highcharts namespace
Highcharts = win.Highcharts = win.Highcharts ? error(16, true) : {};
Highcharts.seriesTypes = seriesTypes;
/**
* Extend an object with the members of another
* @param {Object} a The object to be extended
* @param {Object} b The object to add to the first one
*/
var extend = Highcharts.extend = function (a, b) {
var n;
if (!a) {
a = {};
}
for (n in b) {
a[n] = b[n];
}
return a;
};
/**
* Deep merge two or more objects and return a third object. If the first argument is
* true, the contents of the second object is copied into the first object.
* Previously this function redirected to jQuery.extend(true), but this had two limitations.
* First, it deep merged arrays, which lead to workarounds in Highcharts. Second,
* it copied properties from extended prototypes.
*/
function merge() {
var i,
args = arguments,
len,
ret = {},
doCopy = function (copy, original) {
var value, key;
// An object is replacing a primitive
if (typeof copy !== 'object') {
copy = {};
}
for (key in original) {
if (original.hasOwnProperty(key)) {
value = original[key];
// Copy the contents of objects, but not arrays or DOM nodes
if (value && typeof value === 'object' && Object.prototype.toString.call(value) !== '[object Array]' &&
key !== 'renderTo' && typeof value.nodeType !== 'number') {
copy[key] = doCopy(copy[key] || {}, value);
// Primitives and arrays are copied over directly
} else {
copy[key] = original[key];
}
}
}
return copy;
};
// If first argument is true, copy into the existing object. Used in setOptions.
if (args[0] === true) {
ret = args[1];
args = Array.prototype.slice.call(args, 2);
}
// For each argument, extend the return
len = args.length;
for (i = 0; i < len; i++) {
ret = doCopy(ret, args[i]);
}
return ret;
}
/**
* Shortcut for parseInt
* @param {Object} s
* @param {Number} mag Magnitude
*/
function pInt(s, mag) {
return parseInt(s, mag || 10);
}
/**
* Check for string
* @param {Object} s
*/
function isString(s) {
return typeof s === 'string';
}
/**
* Check for object
* @param {Object} obj
*/
function isObject(obj) {
return obj && typeof obj === 'object';
}
/**
* Check for array
* @param {Object} obj
*/
function isArray(obj) {
return Object.prototype.toString.call(obj) === '[object Array]';
}
/**
* Check for number
* @param {Object} n
*/
function isNumber(n) {
return typeof n === 'number';
}
function log2lin(num) {
return math.log(num) / math.LN10;
}
function lin2log(num) {
return math.pow(10, num);
}
/**
* Remove last occurence of an item from an array
* @param {Array} arr
* @param {Mixed} item
*/
function erase(arr, item) {
var i = arr.length;
while (i--) {
if (arr[i] === item) {
arr.splice(i, 1);
break;
}
}
//return arr;
}
/**
* Returns true if the object is not null or undefined. Like MooTools' $.defined.
* @param {Object} obj
*/
function defined(obj) {
return obj !== UNDEFINED && obj !== null;
}
/**
* Set or get an attribute or an object of attributes. Can't use jQuery attr because
* it attempts to set expando properties on the SVG element, which is not allowed.
*
* @param {Object} elem The DOM element to receive the attribute(s)
* @param {String|Object} prop The property or an abject of key-value pairs
* @param {String} value The value if a single property is set
*/
function attr(elem, prop, value) {
var key,
ret;
// if the prop is a string
if (isString(prop)) {
// set the value
if (defined(value)) {
elem.setAttribute(prop, value);
// get the value
} else if (elem && elem.getAttribute) { // elem not defined when printing pie demo...