ganglia_js_charts 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,11 @@
1
+ /*
2
+ Highcharts JS v2.1.2 (2011-01-12)
3
+ MooTools adapter
4
+
5
+ (c) 2010 Torstein H?nsi
6
+
7
+ License: www.highcharts.com/license
8
+ */
9
+ var HighchartsAdapter={init:function(){var a=Fx.prototype,b=a.start,c=Fx.Morph.prototype,d=c.compute;a.start=function(f){var e=this.element;if(f.d)this.paths=Highcharts.pathAnim.init(e,e.d,this.toD);b.apply(this,arguments)};c.compute=function(f,e,h){var g=this.paths;if(g)this.element.attr("d",Highcharts.pathAnim.step(g[0],g[1],h,this.toD));else return d.apply(this,arguments)}},animate:function(a,b,c){var d=a.attr,f=c&&c.complete;if(d&&!a.setStyle){a.getStyle=a.attr;a.setStyle=function(){var e=arguments;
10
+ a.attr.call(a,e[0],e[1][0])};a.$family=a.uid=true}HighchartsAdapter.stop(a);c=new Fx.Morph(d?a:$(a),$extend({transition:Fx.Transitions.Quad.easeInOut},c));if(b.d)c.toD=b.d;f&&c.addEvent("complete",f);c.start(b);a.fx=c},each:$each,map:function(a,b){return a.map(b)},grep:function(a,b){return a.filter(b)},merge:$merge,hyphenate:function(a){return a.hyphenate()},addEvent:function(a,b,c){if(typeof b=="string"){if(b=="unload")b="beforeunload";if(!a.addEvent)if(a.nodeName)a=$(a);else $extend(a,new Events);
11
+ a.addEvent(b,c)}},removeEvent:function(a,b,c){if(b){if(b=="unload")b="beforeunload";a.removeEvent(b,c)}},fireEvent:function(a,b,c,d){b=new Event({type:b,target:a});b=$extend(b,c);b.preventDefault=function(){d=null};a.fireEvent&&a.fireEvent(b.type,b);d&&d(b)},stop:function(a){a.fx&&a.fx.cancel()}};
@@ -0,0 +1,214 @@
1
+ /**
2
+ * @license Highcharts JS v2.1.2 (2011-01-12)
3
+ * MooTools adapter
4
+ *
5
+ * (c) 2010 Torstein Hønsi
6
+ *
7
+ * License: www.highcharts.com/license
8
+ */
9
+
10
+ // JSLint options:
11
+ /*global Highcharts, Fx, $, $extend, $each, $merge, Events, Event */
12
+
13
+ var HighchartsAdapter = {
14
+ /**
15
+ * Initialize the adapter. This is run once as Highcharts is first run.
16
+ */
17
+ init: function() {
18
+ var fxProto = Fx.prototype,
19
+ fxStart = fxProto.start,
20
+ morphProto = Fx.Morph.prototype,
21
+ morphCompute = morphProto.compute;
22
+
23
+ // override Fx.start to allow animation of SVG element wrappers
24
+ fxProto.start = function(from, to) {
25
+ var fx = this,
26
+ elem = fx.element;
27
+
28
+ // special for animating paths
29
+ if (from.d) {
30
+ //this.fromD = this.element.d.split(' ');
31
+ fx.paths = Highcharts.pathAnim.init(
32
+ elem,
33
+ elem.d,
34
+ fx.toD
35
+ );
36
+ }
37
+ fxStart.apply(fx, arguments);
38
+ };
39
+
40
+ // override Fx.step to allow animation of SVG element wrappers
41
+ morphProto.compute = function(from, to, delta) {
42
+ var fx = this,
43
+ paths = fx.paths;
44
+
45
+ if (paths) {
46
+ fx.element.attr(
47
+ 'd',
48
+ Highcharts.pathAnim.step(paths[0], paths[1], delta, fx.toD)
49
+ );
50
+ } else {
51
+ return morphCompute.apply(fx, arguments);
52
+ }
53
+ };
54
+
55
+ },
56
+
57
+ /**
58
+ * Animate a HTML element or SVG element wrapper
59
+ * @param {Object} el
60
+ * @param {Object} params
61
+ * @param {Object} options jQuery-like animation options: duration, easing, callback
62
+ */
63
+ animate: function (el, params, options) {
64
+ var isSVGElement = el.attr,
65
+ effect,
66
+ complete = options && options.complete;
67
+
68
+ if (isSVGElement && !el.setStyle) {
69
+ // add setStyle and getStyle methods for internal use in Moo
70
+ el.getStyle = el.attr;
71
+ el.setStyle = function() { // property value is given as array in Moo - break it down
72
+ var args = arguments;
73
+ el.attr.call(el, args[0], args[1][0]);
74
+ }
75
+ // dirty hack to trick Moo into handling el as an element wrapper
76
+ el.$family = el.uid = true;
77
+ }
78
+
79
+ // stop running animations
80
+ HighchartsAdapter.stop(el);
81
+
82
+ // define and run the effect
83
+ effect = new Fx.Morph(
84
+ isSVGElement ? el : $(el),
85
+ $extend({
86
+ transition: Fx.Transitions.Quad.easeInOut
87
+ }, options)
88
+ );
89
+
90
+ // special treatment for paths
91
+ if (params.d) {
92
+ effect.toD = params.d;
93
+ }
94
+
95
+ // jQuery-like events
96
+ if (complete) {
97
+ effect.addEvent('complete', complete);
98
+ }
99
+
100
+ // run
101
+ effect.start(params);
102
+
103
+ // record for use in stop method
104
+ el.fx = effect;
105
+ },
106
+
107
+ /**
108
+ * MooTool's each function
109
+ *
110
+ */
111
+ each: $each,
112
+
113
+ /**
114
+ * Map an array
115
+ * @param {Array} arr
116
+ * @param {Function} fn
117
+ */
118
+ map: function (arr, fn){
119
+ return arr.map(fn);
120
+ },
121
+
122
+ /**
123
+ * Grep or filter an array
124
+ * @param {Array} arr
125
+ * @param {Function} fn
126
+ */
127
+ grep: function(arr, fn) {
128
+ return arr.filter(fn);
129
+ },
130
+
131
+ /**
132
+ * Deep merge two objects and return a third
133
+ */
134
+ merge: $merge,
135
+
136
+ /**
137
+ * Hyphenate a string, like minWidth becomes min-width
138
+ * @param {Object} str
139
+ */
140
+ hyphenate: function (str){
141
+ return str.hyphenate();
142
+ },
143
+
144
+ /**
145
+ * Add an event listener
146
+ * @param {Object} el HTML element or custom object
147
+ * @param {String} type Event type
148
+ * @param {Function} fn Event handler
149
+ */
150
+ addEvent: function (el, type, fn) {
151
+ if (typeof type == 'string') { // chart broke due to el being string, type function
152
+
153
+ if (type == 'unload') { // Moo self destructs before custom unload events
154
+ type = 'beforeunload';
155
+ }
156
+
157
+ // if the addEvent method is not defined, el is a custom Highcharts object
158
+ // like series or point
159
+ if (!el.addEvent) {
160
+ if (el.nodeName) {
161
+ el = $(el); // a dynamically generated node
162
+ } else {
163
+ $extend(el, new Events()); // a custom object
164
+ }
165
+ }
166
+
167
+ el.addEvent(type, fn);
168
+ }
169
+ },
170
+
171
+ removeEvent: function(el, type, fn) {
172
+ if (type) {
173
+ if (type == 'unload') { // Moo self destructs before custom unload events
174
+ type = 'beforeunload';
175
+ }
176
+
177
+
178
+ el.removeEvent(type, fn);
179
+ }
180
+ },
181
+
182
+ fireEvent: function(el, event, eventArguments, defaultFunction) {
183
+ // create an event object that keeps all functions
184
+ event = new Event({
185
+ type: event,
186
+ target: el
187
+ });
188
+ event = $extend(event, eventArguments);
189
+ // override the preventDefault function to be able to use
190
+ // this for custom events
191
+ event.preventDefault = function() {
192
+ defaultFunction = null;
193
+ };
194
+ // if fireEvent is not available on the object, there hasn't been added
195
+ // any events to it above
196
+ if (el.fireEvent) {
197
+ el.fireEvent(event.type, event);
198
+ }
199
+
200
+ // fire the default if it is passed and it is not prevented above
201
+ if (defaultFunction) {
202
+ defaultFunction(event);
203
+ }
204
+ },
205
+
206
+ /**
207
+ * Stop running animations on the object
208
+ */
209
+ stop: function (el) {
210
+ if (el.fx) {
211
+ el.fx.cancel();
212
+ }
213
+ }
214
+ };
@@ -0,0 +1,14 @@
1
+ /*
2
+ Highcharts JS v2.1.2 (2011-01-12)
3
+ Prototype adapter
4
+
5
+ @author Michael Nelson, Torstein H?nsi.
6
+
7
+ Feel free to use and modify this script.
8
+ Highcharts license: www.highcharts.com/license.
9
+ */
10
+ var HighchartsAdapter=function(){var l=typeof Effect!="undefined";return{init:function(){if(l)Effect.HighchartsTransition=Class.create(Effect.Base,{initialize:function(a,b,c,d){var e;this.element=a;e=a.attr(b);if(b=="d"){this.paths=Highcharts.pathAnim.init(a,a.d,c);this.toD=c;e=0;c=1}this.start(Object.extend(d||{},{from:e,to:c,attribute:b}))},setup:function(){HighchartsAdapter._extend(this.element);this.element._highchart_animation=this},update:function(a){var b=this.paths;if(b)a=Highcharts.pathAnim.step(b[0],
11
+ b[1],a,this.toD);this.element.attr(this.options.attribute,a)},finish:function(){this.element._highchart_animation=null}})},addEvent:function(a,b,c){if(a.addEventListener||a.attachEvent)Event.observe($(a),b,c);else{HighchartsAdapter._extend(a);a._highcharts_observe(b,c)}},animate:function(a,b,c){var d;c=c||{};c.delay=0;c.duration=(c.duration||500)/1E3;if(l)for(d in b)new Effect.HighchartsTransition($(a),d,b[d],c);else for(d in b)a.attr(d,b[d]);if(!a.attr)throw"Todo: implement animate DOM objects";
12
+ },stop:function(a){a._highcharts_extended&&a._highchart_animation&&a._highchart_animation.cancel()},each:function(a,b){$A(a).each(b)},fireEvent:function(a,b,c,d){if(b.preventDefault)d=null;if(a.fire)a.fire(b,c);else a._highcharts_extended&&a._highcharts_fire(b,c);d&&d(c)},removeEvent:function(a,b,c){if($(a).stopObserving)a.stopObserving(a,b,c);else{HighchartsAdapter._extend(a);a._highcharts_stop_observing(b,c)}},grep:function(a,b){return a.findAll(b)},hyphenate:function(a){return a.replace(/([A-Z])/g,
13
+ function(b,c){return"-"+c.toLowerCase()})},map:function(a,b){return a.map(b)},merge:function(){function a(e,i){var f,g,h,j,k;for(g in i){f=i[g];h=typeof f==="undefined";j=f===null;k=i===e[g];if(!(h||j||k)){h=typeof f==="object";j=f&&h&&f.constructor==Array;k=!!f.nodeType;e[g]=h&&!j&&!k?a(typeof e[g]=="object"?e[g]:{},f):i[g]}}return e}for(var b=arguments,c={},d=0;d<b.length;d++)c=a(c,b[d]);return c},_extend:function(a){a._highcharts_extended||Object.extend(a,{_highchart_events:{},_highchart_animation:null,
14
+ _highcharts_extended:true,_highcharts_observe:function(b,c){this._highchart_events[b]=[this._highchart_events[b],c].compact().flatten()},_highcharts_stop_observing:function(b,c){this._highchart_events[b]=[this._highchart_events[b]].compact().flatten().without(c)},_highcharts_fire:function(b,c){(this._highchart_events[b]||[]).each(function(d){c&&c.stopped||d.bind(this)(c)}.bind(this))}})}}}();
@@ -0,0 +1,254 @@
1
+ /**
2
+ * @license Highcharts JS v2.1.2 (2011-01-12)
3
+ * Prototype adapter
4
+ *
5
+ * @author Michael Nelson, Torstein Hønsi.
6
+ *
7
+ * Feel free to use and modify this script.
8
+ * Highcharts license: www.highcharts.com/license.
9
+ */
10
+
11
+ /*
12
+ * Known issues:
13
+ * - Some grid lines land in wrong position - http://jsfiddle.net/highcharts/jaRhY/28
14
+ */
15
+
16
+ // JSLint options:
17
+ /*jslint forin: true */
18
+ /*global Effect, Class, Highcharts, Event, $, $A */
19
+
20
+ // Adapter interface between prototype and the Highcarts charting library
21
+ var HighchartsAdapter = (function() {
22
+
23
+ var hasEffect = typeof Effect != 'undefined';
24
+
25
+ return {
26
+
27
+ init: function() {
28
+
29
+ if (hasEffect) {
30
+ /**
31
+ * Animation for Highcharts SVG element wrappers only
32
+ * @param {Object} element
33
+ * @param {Object} attribute
34
+ * @param {Object} to
35
+ * @param {Object} options
36
+ */
37
+ Effect.HighchartsTransition = Class.create(Effect.Base, {
38
+ initialize: function(element, attr, to, options){
39
+ var from,
40
+ opts;
41
+
42
+ this.element = element;
43
+
44
+ from = element.attr(attr);
45
+
46
+ // special treatment for paths
47
+ if (attr == 'd') {
48
+ this.paths = Highcharts.pathAnim.init(
49
+ element,
50
+ element.d,
51
+ to
52
+ );
53
+ this.toD = to;
54
+
55
+
56
+ // fake values in order to read relative position as a float in update
57
+ from = 0;
58
+ to = 1;
59
+ }
60
+
61
+ opts = Object.extend((options || {}), {
62
+ from: from,
63
+ to: to,
64
+ attribute: attr
65
+ });
66
+ this.start(opts);
67
+ },
68
+ setup: function(){
69
+ HighchartsAdapter._extend(this.element);
70
+ this.element._highchart_animation = this;
71
+ },
72
+ update: function(position) {
73
+ var paths = this.paths;
74
+
75
+ if (paths) {
76
+ position = Highcharts.pathAnim.step(paths[0], paths[1], position, this.toD);
77
+ }
78
+
79
+ this.element.attr(this.options.attribute, position);
80
+ },
81
+ finish: function(){
82
+ this.element._highchart_animation = null;
83
+ }
84
+ });
85
+ }
86
+ },
87
+
88
+ // el needs an event to be attached. el is not necessarily a dom element
89
+ addEvent: function(el, event, fn) {
90
+ if (el.addEventListener || el.attachEvent) {
91
+ Event.observe($(el), event, fn);
92
+
93
+ } else {
94
+ HighchartsAdapter._extend(el);
95
+ el._highcharts_observe(event, fn);
96
+ }
97
+ },
98
+
99
+ // motion makes things pretty. use it if effects is loaded, if not... still get to the end result.
100
+ animate: function(el, params, options) {
101
+ var key,
102
+ fx;
103
+
104
+ // default options
105
+ options = options || {};
106
+ options.delay = 0;
107
+ options.duration = (options.duration || 500) / 1000;
108
+
109
+ // animate wrappers and DOM elements
110
+ if (hasEffect) {
111
+ for (key in params) {
112
+ fx = new Effect.HighchartsTransition($(el), key, params[key], options);
113
+ }
114
+ } else {
115
+ for (key in params) {
116
+ el.attr(key, params[key]);
117
+ }
118
+ }
119
+
120
+ if (!el.attr) {
121
+ throw 'Todo: implement animate DOM objects';
122
+ }
123
+ },
124
+
125
+ // this only occurs in higcharts 2.0+
126
+ stop: function(el){
127
+ if (el._highcharts_extended && el._highchart_animation) {
128
+ el._highchart_animation.cancel();
129
+ }
130
+ },
131
+
132
+ // um.. each
133
+ each: function(arr, fn){
134
+ $A(arr).each(fn);
135
+ },
136
+
137
+ // fire an event based on an event name (event) and an object (el).
138
+ // again, el may not be a dom element
139
+ fireEvent: function(el, event, eventArguments, defaultFunction){
140
+ if (event.preventDefault) {
141
+ defaultFunction = null;
142
+ }
143
+
144
+ if (el.fire) {
145
+ el.fire(event, eventArguments);
146
+ } else if (el._highcharts_extended) {
147
+ el._highcharts_fire(event, eventArguments);
148
+ }
149
+
150
+ if (defaultFunction) {
151
+ defaultFunction(eventArguments);
152
+ }
153
+ },
154
+
155
+ removeEvent: function(el, event, handler){
156
+ if ($(el).stopObserving) {
157
+ el.stopObserving(el, event, handler);
158
+
159
+ } else {
160
+ HighchartsAdapter._extend(el);
161
+ el._highcharts_stop_observing(event, handler);
162
+ }
163
+ },
164
+
165
+ // um, grep
166
+ grep: function(arr, fn){
167
+ return arr.findAll(fn);
168
+ },
169
+
170
+ // change leftPadding to left-padding
171
+ hyphenate: function(str){
172
+ return str.replace(/([A-Z])/g, function(a, b){
173
+ return '-' + b.toLowerCase();
174
+ });
175
+ },
176
+
177
+ // um, map
178
+ map: function(arr, fn){
179
+ return arr.map(fn);
180
+ },
181
+
182
+ // deep merge. merge({a : 'a', b : {b1 : 'b1', b2 : 'b2'}}, {b : {b2 : 'b2_prime'}, c : 'c'}) => {a : 'a', b : {b1 : 'b1', b2 : 'b2_prime'}, c : 'c'}
183
+ merge: function(){
184
+ function doCopy(copy, original) {
185
+ var value,
186
+ key,
187
+ undef,
188
+ nil,
189
+ same,
190
+ obj,
191
+ arr,
192
+ node;
193
+
194
+ for (key in original) {
195
+ value = original[key];
196
+ undef = typeof(value) === 'undefined';
197
+ nil = value === null;
198
+ same = original === copy[key];
199
+
200
+ if (undef || nil || same) {
201
+ continue;
202
+ }
203
+
204
+ obj = typeof(value) === 'object';
205
+ arr = value && obj && value.constructor == Array;
206
+ node = !!value.nodeType;
207
+
208
+ if (obj && !arr && !node) {
209
+ copy[key] = doCopy(typeof copy[key] == 'object' ? copy[key] : {}, value);
210
+ }
211
+ else {
212
+ copy[key] = original[key];
213
+ }
214
+ }
215
+ return copy;
216
+ }
217
+
218
+ var args = arguments, retVal = {};
219
+
220
+ for (var i = 0; i < args.length; i++) {
221
+ retVal = doCopy(retVal, args[i]);
222
+ }
223
+
224
+ return retVal;
225
+ },
226
+
227
+ // extend an object to handle highchart events (highchart objects, not svg elements).
228
+ // this is a very simple way of handling events but whatever, it works (i think)
229
+ _extend: function(object){
230
+ if (!object._highcharts_extended) {
231
+ Object.extend(object, {
232
+ _highchart_events: {},
233
+ _highchart_animation: null,
234
+ _highcharts_extended: true,
235
+ _highcharts_observe: function(name, fn){
236
+ this._highchart_events[name] = [this._highchart_events[name], fn].compact().flatten();
237
+ },
238
+ _highcharts_stop_observing: function(name, fn){
239
+ this._highchart_events[name] = [this._highchart_events[name]].compact().flatten().without(fn);
240
+ },
241
+ _highcharts_fire: function(name, args){
242
+ (this._highchart_events[name] || []).each(function(fn){
243
+ if (args && args.stopped) {
244
+ return; // "throw $break" wasn't working. i think because of the scope of 'this'.
245
+ }
246
+ fn.bind(this)(args);
247
+ }
248
+ .bind(this));
249
+ }
250
+ });
251
+ }
252
+ }
253
+ };
254
+ })();