initial commit
This commit is contained in:
12
WebRoot/js/highstock/adapters/mootools-adapter.js
Normal file
12
WebRoot/js/highstock/adapters/mootools-adapter.js
Normal file
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
Highcharts Stock v1.0 Beta (2011-07-05)
|
||||
MooTools adapter
|
||||
|
||||
(c) 2010-2011 Torstein H?nsi
|
||||
|
||||
License: www.highcharts.com/license
|
||||
*/
|
||||
(function(){var g=window,j=!!g.$merge,h=g.$extend||function(){return Object.append.apply(Object,arguments)};g.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);return this};c.compute=function(f,e,k){var i=this.paths;if(i)this.element.attr("d",Highcharts.pathAnim.step(i[0],i[1],k,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;a.attr.call(a,e[0],e[1][0])};a.$family=a.uid=true}HighchartsAdapter.stop(a);c=new Fx.Morph(d?a:$(a),h({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:function(a,b){return j?$each(a,b):a.each(b)},map:function(a,b){return a.map(b)},grep:function(a,b){return a.filter(b)},merge:function(){var a=arguments,b=[{}],c=a.length;if(j)a=
|
||||
$merge.apply(null,a);else{for(;c--;)b[c+1]=a[c];a=Object.merge.apply(Object,b)}return a},addEvent:function(a,b,c){if(typeof b=="string"){if(b=="unload")b="beforeunload";if(!a.addEvent)if(a.nodeName)a=$(a);else h(a,new Events);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=h(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()}}})();
|
||||
238
WebRoot/js/highstock/adapters/mootools-adapter.src.js
Normal file
238
WebRoot/js/highstock/adapters/mootools-adapter.src.js
Normal file
@@ -0,0 +1,238 @@
|
||||
/**
|
||||
* @license Highcharts Stock v1.0 Beta (2011-07-05)
|
||||
* MooTools adapter
|
||||
*
|
||||
* (c) 2010-2011 Torstein Hønsi
|
||||
*
|
||||
* License: www.highcharts.com/license
|
||||
*/
|
||||
|
||||
// JSLint options:
|
||||
/*global Highcharts, Fx, $, $extend, $each, $merge, Events, Event */
|
||||
|
||||
(function() {
|
||||
|
||||
var win = window,
|
||||
legacy = !!win.$merge,
|
||||
$extend = win.$extend || function() {
|
||||
return Object.append.apply(Object, arguments)
|
||||
};
|
||||
|
||||
win.HighchartsAdapter = {
|
||||
/**
|
||||
* Initialize the adapter. This is run once as Highcharts is first run.
|
||||
*/
|
||||
init: function() {
|
||||
var fxProto = Fx.prototype,
|
||||
fxStart = fxProto.start,
|
||||
morphProto = Fx.Morph.prototype,
|
||||
morphCompute = morphProto.compute;
|
||||
|
||||
// override Fx.start to allow animation of SVG element wrappers
|
||||
fxProto.start = function(from, to) {
|
||||
var fx = this,
|
||||
elem = fx.element;
|
||||
|
||||
// special for animating paths
|
||||
if (from.d) {
|
||||
//this.fromD = this.element.d.split(' ');
|
||||
fx.paths = Highcharts.pathAnim.init(
|
||||
elem,
|
||||
elem.d,
|
||||
fx.toD
|
||||
);
|
||||
}
|
||||
fxStart.apply(fx, arguments);
|
||||
|
||||
return this; // chainable
|
||||
};
|
||||
|
||||
// override Fx.step to allow animation of SVG element wrappers
|
||||
morphProto.compute = function(from, to, delta) {
|
||||
var fx = this,
|
||||
paths = fx.paths;
|
||||
|
||||
if (paths) {
|
||||
fx.element.attr(
|
||||
'd',
|
||||
Highcharts.pathAnim.step(paths[0], paths[1], delta, fx.toD)
|
||||
);
|
||||
} else {
|
||||
return morphCompute.apply(fx, arguments);
|
||||
}
|
||||
};
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Animate a HTML element or SVG element wrapper
|
||||
* @param {Object} el
|
||||
* @param {Object} params
|
||||
* @param {Object} options jQuery-like animation options: duration, easing, callback
|
||||
*/
|
||||
animate: function (el, params, options) {
|
||||
var isSVGElement = el.attr,
|
||||
effect,
|
||||
complete = options && options.complete;
|
||||
|
||||
if (isSVGElement && !el.setStyle) {
|
||||
// add setStyle and getStyle methods for internal use in Moo
|
||||
el.getStyle = el.attr;
|
||||
el.setStyle = function() { // property value is given as array in Moo - break it down
|
||||
var args = arguments;
|
||||
el.attr.call(el, args[0], args[1][0]);
|
||||
}
|
||||
// dirty hack to trick Moo into handling el as an element wrapper
|
||||
el.$family = el.uid = true;
|
||||
}
|
||||
|
||||
// stop running animations
|
||||
HighchartsAdapter.stop(el);
|
||||
|
||||
// define and run the effect
|
||||
effect = new Fx.Morph(
|
||||
isSVGElement ? el : $(el),
|
||||
$extend({
|
||||
transition: Fx.Transitions.Quad.easeInOut
|
||||
}, options)
|
||||
);
|
||||
|
||||
// special treatment for paths
|
||||
if (params.d) {
|
||||
effect.toD = params.d;
|
||||
}
|
||||
|
||||
// jQuery-like events
|
||||
if (complete) {
|
||||
effect.addEvent('complete', complete);
|
||||
}
|
||||
|
||||
// run
|
||||
effect.start(params);
|
||||
|
||||
// record for use in stop method
|
||||
el.fx = effect;
|
||||
},
|
||||
|
||||
/**
|
||||
* MooTool's each function
|
||||
*
|
||||
*/
|
||||
each: function(arr, fn) {
|
||||
return legacy ?
|
||||
$each(arr, fn) :
|
||||
arr.each(fn);
|
||||
},
|
||||
|
||||
/**
|
||||
* Map an array
|
||||
* @param {Array} arr
|
||||
* @param {Function} fn
|
||||
*/
|
||||
map: function (arr, fn){
|
||||
return arr.map(fn);
|
||||
},
|
||||
|
||||
/**
|
||||
* Grep or filter an array
|
||||
* @param {Array} arr
|
||||
* @param {Function} fn
|
||||
*/
|
||||
grep: function(arr, fn) {
|
||||
return arr.filter(fn);
|
||||
},
|
||||
|
||||
/**
|
||||
* Deep merge two objects and return a third
|
||||
*/
|
||||
merge: function() {
|
||||
var args = arguments,
|
||||
args13 = [{}], // MooTools 1.3+
|
||||
i = args.length,
|
||||
ret;
|
||||
|
||||
if (legacy) {
|
||||
ret = $merge.apply(null, args);
|
||||
} else {
|
||||
while (i--) {
|
||||
args13[i + 1] = args[i];
|
||||
}
|
||||
ret = Object.merge.apply(Object, args13);
|
||||
}
|
||||
|
||||
return ret;
|
||||
},
|
||||
|
||||
/**
|
||||
* Add an event listener
|
||||
* @param {Object} el HTML element or custom object
|
||||
* @param {String} type Event type
|
||||
* @param {Function} fn Event handler
|
||||
*/
|
||||
addEvent: function (el, type, fn) {
|
||||
if (typeof type == 'string') { // chart broke due to el being string, type function
|
||||
|
||||
if (type == 'unload') { // Moo self destructs before custom unload events
|
||||
type = 'beforeunload';
|
||||
}
|
||||
|
||||
// if the addEvent method is not defined, el is a custom Highcharts object
|
||||
// like series or point
|
||||
if (!el.addEvent) {
|
||||
if (el.nodeName) {
|
||||
el = $(el); // a dynamically generated node
|
||||
} else {
|
||||
$extend(el, new Events()); // a custom object
|
||||
}
|
||||
}
|
||||
|
||||
el.addEvent(type, fn);
|
||||
}
|
||||
},
|
||||
|
||||
removeEvent: function(el, type, fn) {
|
||||
if (type) {
|
||||
if (type == 'unload') { // Moo self destructs before custom unload events
|
||||
type = 'beforeunload';
|
||||
}
|
||||
|
||||
|
||||
el.removeEvent(type, fn);
|
||||
}
|
||||
},
|
||||
|
||||
fireEvent: function(el, event, eventArguments, defaultFunction) {
|
||||
// create an event object that keeps all functions
|
||||
event = new Event({
|
||||
type: event,
|
||||
target: el
|
||||
});
|
||||
event = $extend(event, eventArguments);
|
||||
// override the preventDefault function to be able to use
|
||||
// this for custom events
|
||||
event.preventDefault = function() {
|
||||
defaultFunction = null;
|
||||
};
|
||||
// if fireEvent is not available on the object, there hasn't been added
|
||||
// any events to it above
|
||||
if (el.fireEvent) {
|
||||
el.fireEvent(event.type, event);
|
||||
}
|
||||
|
||||
// fire the default if it is passed and it is not prevented above
|
||||
if (defaultFunction) {
|
||||
defaultFunction(event);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Stop running animations on the object
|
||||
*/
|
||||
stop: function (el) {
|
||||
if (el.fx) {
|
||||
el.fx.cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
})();
|
||||
14
WebRoot/js/highstock/adapters/prototype-adapter.js
vendored
Normal file
14
WebRoot/js/highstock/adapters/prototype-adapter.js
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
/*
|
||||
Highcharts Stock v1.0 Beta (2011-07-05)
|
||||
Prototype adapter
|
||||
|
||||
@author Michael Nelson, Torstein H?nsi.
|
||||
|
||||
Feel free to use and modify this script.
|
||||
Highcharts license: www.highcharts.com/license.
|
||||
*/
|
||||
var HighchartsAdapter=function(){var f=typeof Effect!="undefined";return{init:function(){if(f)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],
|
||||
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(f)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";
|
||||
},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(b,c);else{HighchartsAdapter._extend(a);a._highcharts_stop_observing(b,c)}},grep:function(a,b){return a.findAll(b)},map:function(a,b){return a.map(b)},merge:function(){function a(b,
|
||||
c){var d,e;for(e in c){d=c[e];b[e]=d&&typeof d=="object"&&d.constructor!=Array&&typeof d.nodeType!=="number"?a(b[e]||{},d):c[e]}return b}return function(){for(var b=arguments,c={},d=0;d<b.length;d++)c=a(c,b[d]);return c}.apply(this,arguments)},_extend:function(a){a._highcharts_extended||Object.extend(a,{_highchart_events:{},_highchart_animation:null,_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))}})}}}();
|
||||
277
WebRoot/js/highstock/adapters/prototype-adapter.src.js
vendored
Normal file
277
WebRoot/js/highstock/adapters/prototype-adapter.src.js
vendored
Normal file
@@ -0,0 +1,277 @@
|
||||
/**
|
||||
* @license Highcharts Stock v1.0 Beta (2011-07-05)
|
||||
* Prototype adapter
|
||||
*
|
||||
* @author Michael Nelson, Torstein Hønsi.
|
||||
*
|
||||
* Feel free to use and modify this script.
|
||||
* Highcharts license: www.highcharts.com/license.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Known issues:
|
||||
* - Some grid lines land in wrong position - http://jsfiddle.net/highcharts/jaRhY/28
|
||||
*/
|
||||
|
||||
// JSLint options:
|
||||
/*jslint forin: true */
|
||||
/*global Effect, Class, Highcharts, Event, $, $A */
|
||||
|
||||
// Adapter interface between prototype and the Highcarts charting library
|
||||
var HighchartsAdapter = (function() {
|
||||
|
||||
var hasEffect = typeof Effect != 'undefined';
|
||||
|
||||
return {
|
||||
|
||||
init: function() {
|
||||
|
||||
if (hasEffect) {
|
||||
/**
|
||||
* Animation for Highcharts SVG element wrappers only
|
||||
* @param {Object} element
|
||||
* @param {Object} attribute
|
||||
* @param {Object} to
|
||||
* @param {Object} options
|
||||
*/
|
||||
Effect.HighchartsTransition = Class.create(Effect.Base, {
|
||||
initialize: function(element, attr, to, options){
|
||||
var from,
|
||||
opts;
|
||||
|
||||
this.element = element;
|
||||
|
||||
from = element.attr(attr);
|
||||
|
||||
// special treatment for paths
|
||||
if (attr == 'd') {
|
||||
this.paths = Highcharts.pathAnim.init(
|
||||
element,
|
||||
element.d,
|
||||
to
|
||||
);
|
||||
this.toD = to;
|
||||
|
||||
|
||||
// fake values in order to read relative position as a float in update
|
||||
from = 0;
|
||||
to = 1;
|
||||
}
|
||||
|
||||
opts = Object.extend((options || {}), {
|
||||
from: from,
|
||||
to: to,
|
||||
attribute: attr
|
||||
});
|
||||
this.start(opts);
|
||||
},
|
||||
setup: function(){
|
||||
HighchartsAdapter._extend(this.element);
|
||||
this.element._highchart_animation = this;
|
||||
},
|
||||
update: function(position) {
|
||||
var paths = this.paths;
|
||||
|
||||
if (paths) {
|
||||
position = Highcharts.pathAnim.step(paths[0], paths[1], position, this.toD);
|
||||
}
|
||||
|
||||
this.element.attr(this.options.attribute, position);
|
||||
},
|
||||
finish: function(){
|
||||
this.element._highchart_animation = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// el needs an event to be attached. el is not necessarily a dom element
|
||||
addEvent: function(el, event, fn) {
|
||||
if (el.addEventListener || el.attachEvent) {
|
||||
Event.observe($(el), event, fn);
|
||||
|
||||
} else {
|
||||
HighchartsAdapter._extend(el);
|
||||
el._highcharts_observe(event, fn);
|
||||
}
|
||||
},
|
||||
|
||||
// motion makes things pretty. use it if effects is loaded, if not... still get to the end result.
|
||||
animate: function(el, params, options) {
|
||||
var key,
|
||||
fx;
|
||||
|
||||
// default options
|
||||
options = options || {};
|
||||
options.delay = 0;
|
||||
options.duration = (options.duration || 500) / 1000;
|
||||
|
||||
// animate wrappers and DOM elements
|
||||
if (hasEffect) {
|
||||
for (key in params) {
|
||||
fx = new Effect.HighchartsTransition($(el), key, params[key], options);
|
||||
}
|
||||
} else {
|
||||
for (key in params) {
|
||||
el.attr(key, params[key]);
|
||||
}
|
||||
}
|
||||
|
||||
if (!el.attr) {
|
||||
throw 'Todo: implement animate DOM objects';
|
||||
}
|
||||
},
|
||||
|
||||
// this only occurs in higcharts 2.0+
|
||||
stop: function(el){
|
||||
if (el._highcharts_extended && el._highchart_animation) {
|
||||
el._highchart_animation.cancel();
|
||||
}
|
||||
},
|
||||
|
||||
// um.. each
|
||||
each: function(arr, fn){
|
||||
$A(arr).each(fn);
|
||||
},
|
||||
|
||||
// fire an event based on an event name (event) and an object (el).
|
||||
// again, el may not be a dom element
|
||||
fireEvent: function(el, event, eventArguments, defaultFunction){
|
||||
if (event.preventDefault) {
|
||||
defaultFunction = null;
|
||||
}
|
||||
|
||||
if (el.fire) {
|
||||
el.fire(event, eventArguments);
|
||||
} else if (el._highcharts_extended) {
|
||||
el._highcharts_fire(event, eventArguments);
|
||||
}
|
||||
|
||||
if (defaultFunction) {
|
||||
defaultFunction(eventArguments);
|
||||
}
|
||||
},
|
||||
|
||||
removeEvent: function(el, event, handler){
|
||||
if ($(el).stopObserving) {
|
||||
$(el).stopObserving(event, handler);
|
||||
|
||||
} else {
|
||||
HighchartsAdapter._extend(el);
|
||||
el._highcharts_stop_observing(event, handler);
|
||||
}
|
||||
},
|
||||
|
||||
// um, grep
|
||||
grep: function(arr, fn){
|
||||
return arr.findAll(fn);
|
||||
},
|
||||
|
||||
// um, map
|
||||
map: function(arr, fn){
|
||||
return arr.map(fn);
|
||||
},
|
||||
|
||||
// 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'}
|
||||
/*merge: function(){
|
||||
function doCopy(copy, original) {
|
||||
var value,
|
||||
key,
|
||||
undef,
|
||||
nil,
|
||||
same,
|
||||
obj,
|
||||
arr,
|
||||
node;
|
||||
|
||||
for (key in original) {
|
||||
value = original[key];
|
||||
undef = typeof(value) === 'undefined';
|
||||
nil = value === null;
|
||||
same = original === copy[key];
|
||||
|
||||
if (undef || nil || same) {
|
||||
continue;
|
||||
}
|
||||
|
||||
obj = typeof(value) === 'object';
|
||||
arr = value && obj && value.constructor == Array;
|
||||
node = !!value.nodeType;
|
||||
|
||||
if (obj && !arr && !node) {
|
||||
copy[key] = doCopy(typeof copy[key] == 'object' ? copy[key] : {}, value);
|
||||
}
|
||||
else {
|
||||
copy[key] = original[key];
|
||||
}
|
||||
}
|
||||
return copy;
|
||||
}
|
||||
|
||||
var args = arguments, retVal = {};
|
||||
|
||||
for (var i = 0; i < args.length; i++) {
|
||||
retVal = doCopy(retVal, args[i]);
|
||||
}
|
||||
|
||||
return retVal;
|
||||
},*/
|
||||
merge: function() { // the built-in prototype merge function doesn't do deep copy
|
||||
function doCopy(copy, original) {
|
||||
var value;
|
||||
|
||||
for (var key in original) {
|
||||
value = original[key];
|
||||
if (value && typeof value == 'object' && value.constructor != Array &&
|
||||
typeof value.nodeType !== 'number') {
|
||||
copy[key] = doCopy(copy[key] || {}, value); // copy
|
||||
|
||||
} else {
|
||||
copy[key] = original[key];
|
||||
}
|
||||
}
|
||||
return copy;
|
||||
}
|
||||
|
||||
function merge() {
|
||||
var args = arguments,
|
||||
retVal = {};
|
||||
|
||||
for (var i = 0; i < args.length; i++) {
|
||||
retVal = doCopy(retVal, args[i])
|
||||
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
return merge.apply(this, arguments);
|
||||
},
|
||||
|
||||
// extend an object to handle highchart events (highchart objects, not svg elements).
|
||||
// this is a very simple way of handling events but whatever, it works (i think)
|
||||
_extend: function(object){
|
||||
if (!object._highcharts_extended) {
|
||||
Object.extend(object, {
|
||||
_highchart_events: {},
|
||||
_highchart_animation: null,
|
||||
_highcharts_extended: true,
|
||||
_highcharts_observe: function(name, fn){
|
||||
this._highchart_events[name] = [this._highchart_events[name], fn].compact().flatten();
|
||||
},
|
||||
_highcharts_stop_observing: function(name, fn){
|
||||
this._highchart_events[name] = [this._highchart_events[name]].compact().flatten().without(fn);
|
||||
},
|
||||
_highcharts_fire: function(name, args){
|
||||
(this._highchart_events[name] || []).each(function(fn){
|
||||
if (args && args.stopped) {
|
||||
return; // "throw $break" wasn't working. i think because of the scope of 'this'.
|
||||
}
|
||||
fn.bind(this)(args);
|
||||
}
|
||||
.bind(this));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
})();
|
||||
Reference in New Issue
Block a user