view release on metacpan or search on metacpan
lib/Devel/SizeMe/Graph/static/jit-yc.js view on Meta::CPAN
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
(function(){window.$jit=function(x){x=x||window;for(var y in $jit){if($jit[y].$extend){x[y]=$jit[y]}}};$jit.version="2.0.1";var c=function(w){return document.getElementById(w)};c.empty=function(){};c.extend=function(y,w){for(var x in (w||{})){y[x]=w...
lib/Devel/SizeMe/Graph/static/jit.js view on Meta::CPAN
(start code js)
st.switchPosition("right", "animate", {
onComplete: function() {
alert('completed!');
}
});
(end code)
*/
switchPosition: function(pos, method, onComplete) {
var Geom = this.geom, Plot = this.fx, that = this;
if(!Plot.busy) {
Plot.busy = true;
this.contract({
onComplete: function() {
Geom.switchOrientation(pos);
that.compute('end', false);
Plot.busy = false;
if(method == 'animate') {
that.onClick(that.clickedNode.id, onComplete);
} else if(method == 'replot') {
that.select(that.clickedNode.id, onComplete);
}
}
}, pos);
}
},
lib/Devel/SizeMe/Graph/static/jit.js view on Meta::CPAN
(start code js)
st.setRoot('nodeId', 'animate', {
onComplete: function() {
alert('complete!');
}
});
(end code)
*/
setRoot: function(id, method, onComplete) {
if(this.busy) return;
this.busy = true;
var that = this, canvas = this.canvas;
var rootNode = this.graph.getNode(this.root);
var clickedNode = this.graph.getNode(id);
function $setRoot() {
if(this.config.multitree && clickedNode.data.$orn) {
var orn = clickedNode.data.$orn;
var opp = {
'left': 'right',
'right': 'left',
'top': 'bottom',
lib/Devel/SizeMe/Graph/static/jit.js view on Meta::CPAN
onShow: function(node) {
if(!node.drawn) {
node.drawn = true;
node.setData('alpha', 1, 'end');
node.setData('alpha', 0);
node.pos.setc(clickedNode.pos.x, clickedNode.pos.y);
}
}
});
this.compute('end');
this.busy = true;
this.fx.animate({
modes: ['linear', 'node-property:alpha'],
onComplete: function() {
that.busy = false;
that.onClick(id, {
onComplete: function() {
onComplete && onComplete.onComplete();
}
});
}
});
}
// delete previous orientations (if any)
lib/Devel/SizeMe/Graph/static/jit.js view on Meta::CPAN
offsetY: config.offsetY || 0
},
setRightLevelToShowConfig: false,
onBeforeRequest: $.empty,
onBeforeContract: $.empty,
onBeforeMove: $.empty,
onBeforeExpand: $.empty
};
var complete = $.merge(this.controller, innerController, options);
if(!this.busy) {
this.busy = true;
var node = this.graph.getNode(id);
this.selectPath(node, this.clickedNode);
this.clickedNode = node;
complete.onBeforeCompute(node);
complete.onBeforeRequest(node);
this.requestNodes(node, {
onComplete: function() {
complete.onBeforeContract(node);
that.contract({
onComplete: function() {
Geom.setRightLevelToShow(node, canvas, complete.setRightLevelToShowConfig);
complete.onBeforeMove(node);
that.move(node, {
Move: complete.Move,
onComplete: function() {
complete.onBeforeExpand(node);
that.expand(node, {
onComplete: function() {
that.busy = false;
complete.onAfterCompute(id);
complete.onComplete();
}
}); // expand
}
}); // move
}
});// contract
}
});// request
lib/Devel/SizeMe/Graph/static/jit.js view on Meta::CPAN
Constructor Options:
See <Options.AreaChart>.
*/
$jit.AreaChart = new Class({
st: null,
colors: ["#416D9C", "#70A35E", "#EBB056", "#C74243", "#83548B", "#909291", "#557EAA"],
selected: {},
busy: false,
initialize: function(opt) {
this.controller = this.config =
$.merge(Options("Canvas", "Margin", "Label", "AreaChart"), {
Label: { type: 'Native' }
}, opt);
//set functions for showLabels and showAggregates
var showLabels = this.config.showLabels,
typeLabels = $.type(showLabels),
showAggregates = this.config.showAggregates,
lib/Devel/SizeMe/Graph/static/jit.js view on Meta::CPAN
(start code js)
areaChart.updateJSON(json, {
onComplete: function() {
alert('update complete!');
}
});
(end code)
*/
updateJSON: function(json, onComplete) {
if(this.busy) return;
this.busy = true;
var delegate = this.delegate,
graph = delegate.graph,
labels = json.label && $.splat(json.label),
values = json.values,
animate = this.config.animate,
that = this,
hashValues = {};
//convert the whole thing into a hash
lib/Devel/SizeMe/Graph/static/jit.js view on Meta::CPAN
}
});
this.normalizeDims();
delegate.compute();
delegate.select(delegate.root);
if(animate) {
delegate.fx.animate({
modes: ['node-property:height:dimArray'],
duration:1500,
onComplete: function() {
that.busy = false;
onComplete && onComplete.onComplete();
}
});
}
},
/*
Method: filter
Filter selected stacks, collapsing all other stacks. You can filter multiple stacks at the same time.
lib/Devel/SizeMe/Graph/static/jit.js view on Meta::CPAN
console.log('done!');
}
});
(end code)
See also:
<AreaChart.restore>.
*/
filter: function(filters, callback) {
if(this.busy) return;
this.busy = true;
if(this.config.Tips.enable) this.delegate.tips.hide();
this.select(false, false, false);
var args = $.splat(filters);
var rt = this.delegate.graph.getNode(this.delegate.root);
var that = this;
this.normalizeDims();
rt.eachAdjacency(function(adj) {
var n = adj.nodeTo,
dimArray = n.getData('dimArray', 'end'),
stringArray = n.getData('stringArray');
n.setData('dimArray', $.map(dimArray, function(d, i) {
return ($.indexOf(args, stringArray[i]) > -1)? d:[0, 0];
}), 'end');
});
this.delegate.fx.animate({
modes: ['node-property:dimArray'],
duration:1500,
onComplete: function() {
that.busy = false;
callback && callback.onComplete();
}
});
},
/*
Method: restore
Sets all stacks that could have been filtered visible.
lib/Devel/SizeMe/Graph/static/jit.js view on Meta::CPAN
(start code js)
areaChart.restore();
(end code)
See also:
<AreaChart.filter>.
*/
restore: function(callback) {
if(this.busy) return;
this.busy = true;
if(this.config.Tips.enable) this.delegate.tips.hide();
this.select(false, false, false);
this.normalizeDims();
var that = this;
this.delegate.fx.animate({
modes: ['node-property:height:dimArray'],
duration:1500,
onComplete: function() {
that.busy = false;
callback && callback.onComplete();
}
});
},
//adds the little brown bar when hovering the node
select: function(id, name, index) {
if(!this.config.selectOnHover) return;
var s = this.selected;
if(s.id != id || s.name != name
|| s.index != index) {
lib/Devel/SizeMe/Graph/static/jit.js view on Meta::CPAN
Constructor Options:
See <Options.BarChart>.
*/
$jit.BarChart = new Class({
st: null,
colors: ["#416D9C", "#70A35E", "#EBB056", "#C74243", "#83548B", "#909291", "#557EAA"],
selected: {},
busy: false,
initialize: function(opt) {
this.controller = this.config =
$.merge(Options("Canvas", "Margin", "Label", "BarChart"), {
Label: { type: 'Native' }
}, opt);
//set functions for showLabels and showAggregates
var showLabels = this.config.showLabels,
typeLabels = $.type(showLabels),
showAggregates = this.config.showAggregates,
lib/Devel/SizeMe/Graph/static/jit.js view on Meta::CPAN
json - The JSON data format. This format is described in <http://blog.thejit.org/2010/04/24/new-javascript-infovis-toolkit-visualizations/#json-data-format>.
Example:
(start code js)
var barChart = new $jit.BarChart(options);
barChart.loadJSON(json);
(end code)
*/
loadJSON: function(json) {
if(this.busy) return;
this.busy = true;
var prefix = $.time(),
ch = [],
delegate = this.delegate,
name = $.splat(json.label),
color = $.splat(json.color || this.colors),
config = this.config,
gradient = !!config.type.split(":")[1],
animate = config.animate,
horz = config.orientation == 'horizontal',
lib/Devel/SizeMe/Graph/static/jit.js view on Meta::CPAN
this.normalizeDims();
delegate.compute();
delegate.select(delegate.root);
if(animate) {
if(horz) {
delegate.fx.animate({
modes: ['node-property:width:dimArray'],
duration:1500,
onComplete: function() {
that.busy = false;
}
});
} else {
delegate.fx.animate({
modes: ['node-property:height:dimArray'],
duration:1500,
onComplete: function() {
that.busy = false;
}
});
}
} else {
this.busy = false;
}
},
/*
Method: updateJSON
Use this method when updating values for the current JSON data. If the items specified by the JSON data already exist in the graph then their values will be updated.
Parameters:
lib/Devel/SizeMe/Graph/static/jit.js view on Meta::CPAN
(start code js)
barChart.updateJSON(json, {
onComplete: function() {
alert('update complete!');
}
});
(end code)
*/
updateJSON: function(json, onComplete) {
if(this.busy) return;
this.busy = true;
this.select(false, false, false);
var delegate = this.delegate;
var graph = delegate.graph;
var values = json.values;
var animate = this.config.animate;
var that = this;
var horz = this.config.orientation == 'horizontal';
$.each(values, function(v) {
var n = graph.getByName(v.label);
if(n) {
lib/Devel/SizeMe/Graph/static/jit.js view on Meta::CPAN
});
this.normalizeDims();
delegate.compute();
delegate.select(delegate.root);
if(animate) {
if(horz) {
delegate.fx.animate({
modes: ['node-property:width:dimArray'],
duration:1500,
onComplete: function() {
that.busy = false;
onComplete && onComplete.onComplete();
}
});
} else {
delegate.fx.animate({
modes: ['node-property:height:dimArray'],
duration:1500,
onComplete: function() {
that.busy = false;
onComplete && onComplete.onComplete();
}
});
}
}
},
//adds the little brown bar when hovering the node
select: function(id, name) {
if(!this.config.hoveredColor) return;
lib/Devel/SizeMe/Graph/static/jit.js view on Meta::CPAN
}
};
this.graph = new Graph(this.graphOptions, this.config.Node,
this.config.Edge);
this.labels = new $Sunburst.Label[canvasConfig.Label.type](this);
this.fx = new $Sunburst.Plot(this, $Sunburst);
this.op = new $Sunburst.Op(this);
this.json = null;
this.root = null;
this.rotated = null;
this.busy = false;
// initialize extras
this.initializeExtras();
},
/*
createLevelDistanceFunc
Returns the levelDistance function used for calculating a node distance
to its origin. This function returns a function that is computed
lib/Devel/SizeMe/Graph/static/jit.js view on Meta::CPAN
var p = n.getPos(prop);
p.theta += theta;
if (p.theta < 0) {
p.theta += Math.PI * 2;
}
});
if (method == 'animate') {
this.fx.animate(options);
} else if (method == 'replot') {
this.fx.plot();
this.busy = false;
}
},
/*
Method: plot
Plots the Sunburst. This is a shortcut to *fx.plot*.
*/
plot: function() {
this.fx.plot();
lib/Devel/SizeMe/Graph/static/jit.js view on Meta::CPAN
Constructor Options:
See <Options.PieChart>.
*/
$jit.PieChart = new Class({
sb: null,
colors: ["#416D9C", "#70A35E", "#EBB056", "#C74243", "#83548B", "#909291", "#557EAA"],
selected: {},
busy: false,
initialize: function(opt) {
this.controller = this.config =
$.merge(Options("Canvas", "PieChart", "Label"), {
Label: { type: 'Native' }
}, opt);
this.initializeViz();
},
initializeViz: function() {
lib/Devel/SizeMe/Graph/static/jit.js view on Meta::CPAN
(start code js)
pieChart.updateJSON(json, {
onComplete: function() {
alert('update complete!');
}
});
(end code)
*/
updateJSON: function(json, onComplete) {
if(this.busy) return;
this.busy = true;
var delegate = this.delegate;
var graph = delegate.graph;
var values = json.values;
var animate = this.config.animate;
var that = this;
$.each(values, function(v) {
var n = graph.getByName(v.label),
vals = $.splat(v.values);
if(n) {
lib/Devel/SizeMe/Graph/static/jit.js view on Meta::CPAN
}
}
});
this.normalizeDims();
if(animate) {
delegate.compute('end');
delegate.fx.animate({
modes: ['node-property:dimArray:span', 'linear'],
duration:1500,
onComplete: function() {
that.busy = false;
onComplete && onComplete.onComplete();
}
});
} else {
delegate.refresh();
}
},
//adds the little brown bar when hovering the node
select: function(id, name) {
lib/Devel/SizeMe/Graph/static/jit.js view on Meta::CPAN
Method: enter
Sets the node as root.
Parameters:
node - (object) A <Graph.Node>.
*/
enter: function (node) {
if (this.busy)
return;
this.busy = true;
var that = this,
config = this.config;
var callback = {
onComplete: function() {
//compute positions of newly inserted nodes
if(config.request)
that.compute();
lib/Devel/SizeMe/Graph/static/jit.js view on Meta::CPAN
duration: 500,
modes:['node-property:alpha'],
onComplete: function() {
that.clickedNode = node;
that.compute('end');
that.fx.animate({
modes:['linear', 'node-property:width:height'],
duration: 1000,
onComplete: function() {
that.busy = false;
that.clickedNode = node;
}
});
}
});
} else {
that.clickedNode = node;
that.busy = false;
that.refresh();
}
}
};
if(config.request) {
this.requestNodes(clickedNode, callback);
} else {
callback.onComplete();
}
},
/*
Method: out
Sets the parent node of the current selected node as root.
*/
out: function(){
if(this.busy)
return;
var that = this,
GUtil = Graph.Util,
config = this.config,
graph = this.graph,
parents = GUtil.getParents(graph.getNode(this.clickedNode && this.clickedNode.id || this.root)),
parent = parents[0],
clickedNode = parent,
previousClickedNode = this.clickedNode;
this.busy = true;
this.events.hoveredNode = false;
if(!parent) {
this.busy = false;
return;
}
//final plot callback
callback = {
onComplete: function() {
that.clickedNode = parent;
if(config.request) {
that.requestNodes(parent, {
onComplete: function() {
that.compute();
that.plot();
that.busy = false;
}
});
} else {
that.compute();
that.plot();
that.busy = false;
}
}
};
//animate node positions
if(config.animate) {
this.clickedNode = clickedNode;
this.compute('end');
//animate the visible subtree only
this.clickedNode = previousClickedNode;
lib/Devel/SizeMe/Graph/static/jit.js view on Meta::CPAN
'exist': true,
'drawn': true
}
};
this.graph = new Graph(this.graphOptions, this.config.Node,
this.config.Edge);
this.labels = new $ForceDirected.Label[canvasConfig.Label.type](this);
this.fx = new $ForceDirected.Plot(this, $ForceDirected);
this.op = new $ForceDirected.Op(this);
this.json = null;
this.busy = false;
// initialize extras
this.initializeExtras();
},
/*
Method: refresh
Computes positions and plots the tree.
*/
refresh: function() {
lib/Devel/SizeMe/Graph/static/jit.js view on Meta::CPAN
}
};
this.graph = new Graph(this.graphOptions, this.config.Node,
this.config.Edge);
this.labels = new TM.Label[canvasConfig.Label.type](this);
this.fx = new TM.Plot(this);
this.op = new TM.Op(this);
this.group = new TM.Group(this);
this.geom = new TM.Geom(this);
this.clickedNode = null;
this.busy = false;
// initialize extras
this.initializeExtras();
},
/*
Method: refresh
Computes positions and plots the tree.
*/
refresh: function(){
if(this.busy) return;
this.busy = true;
var that = this;
if(this.config.animate) {
this.compute('end');
this.config.levelsToShow > 0 && this.geom.setRightLevelToShow(this.graph.getNode(this.clickedNode
&& this.clickedNode.id || this.root));
this.fx.animate($.merge(this.config, {
modes: ['linear', 'node-property:width:height'],
onComplete: function() {
that.busy = false;
}
}));
} else {
var labelType = this.config.Label.type;
if(labelType != 'Native') {
var that = this;
this.graph.eachNode(function(n) { that.labels.hideLabel(n, false); });
}
this.busy = false;
this.compute();
this.config.levelsToShow > 0 && this.geom.setRightLevelToShow(this.graph.getNode(this.clickedNode
&& this.clickedNode.id || this.root));
this.plot();
}
},
/*
Method: plot
lib/Devel/SizeMe/Graph/static/jit.js view on Meta::CPAN
Method: enter
Sets the node as root.
Parameters:
n - (object) A <Graph.Node>.
*/
enter: function(n){
if(this.busy) return;
this.busy = true;
var that = this,
config = this.config,
graph = this.graph,
clickedNode = n,
previousClickedNode = this.clickedNode;
var callback = {
onComplete: function() {
//ensure that nodes are shown for that level
lib/Devel/SizeMe/Graph/static/jit.js view on Meta::CPAN
//compute end positions
that.clickedNode = clickedNode;
that.compute('end');
//animate positions
//TODO(nico) commenting this line didn't seem to throw errors...
that.clickedNode = previousClickedNode;
that.fx.animate({
modes:['linear', 'node-property:width:height'],
duration: 1000,
onComplete: function() {
that.busy = false;
//TODO(nico) check comment above
that.clickedNode = clickedNode;
}
});
}
});
} else {
that.busy = false;
that.clickedNode = n;
that.refresh();
}
}
};
if(config.request) {
this.requestNodes(clickedNode, callback);
} else {
callback.onComplete();
}
},
/*
Method: out
Sets the parent node of the current selected node as root.
*/
out: function(){
if(this.busy) return;
this.busy = true;
this.events.hoveredNode = false;
var that = this,
config = this.config,
graph = this.graph,
parents = graph.getNode(this.clickedNode
&& this.clickedNode.id || this.root).getParents(),
parent = parents[0],
clickedNode = parent,
previousClickedNode = this.clickedNode;
//if no parents return
if(!parent) {
this.busy = false;
return;
}
//final plot callback
callback = {
onComplete: function() {
that.clickedNode = parent;
if(config.request) {
that.requestNodes(parent, {
onComplete: function() {
that.compute();
that.plot();
that.busy = false;
}
});
} else {
that.compute();
that.plot();
that.busy = false;
}
}
};
//prune tree
if (config.levelsToShow > 0)
this.geom.setRightLevelToShow(parent);
//animate node positions
if(config.animate) {
this.clickedNode = clickedNode;
this.compute('end');
lib/Devel/SizeMe/Graph/static/jit.js view on Meta::CPAN
'drawn': true
}
};
this.graph = new Graph(this.graphOptions, this.config.Node,
this.config.Edge);
this.labels = new $RGraph.Label[canvasConfig.Label.type](this);
this.fx = new $RGraph.Plot(this, $RGraph);
this.op = new $RGraph.Op(this);
this.json = null;
this.root = null;
this.busy = false;
this.parent = false;
// initialize extras
this.initializeExtras();
},
/*
createLevelDistanceFunc
Returns the levelDistance function used for calculating a node distance
lib/Devel/SizeMe/Graph/static/jit.js view on Meta::CPAN
(start code js)
rgraph.onClick('someid');
//or also...
rgraph.onClick('someid', {
hideLabels: false
});
(end code)
*/
onClick: function(id, opt){
if (this.root != id && !this.busy) {
this.busy = true;
this.root = id;
var that = this;
this.controller.onBeforeCompute(this.graph.getNode(id));
var obj = this.getNodeAndParentAngle(id);
// second constraint
this.tagChildren(obj.parent, id);
this.parent = obj.parent;
this.compute('end');
lib/Devel/SizeMe/Graph/static/jit.js view on Meta::CPAN
onComplete: $.empty
}, opt || {});
this.fx.animate($.merge( {
hideLabels: true,
modes: [
mode
]
}, opt, {
onComplete: function(){
that.busy = false;
opt.onComplete();
}
}));
}
}
});
$jit.RGraph.$extend = true;
(function(RGraph){
lib/Devel/SizeMe/Graph/static/jit.js view on Meta::CPAN
'drawn': true
}
};
this.graph = new Graph(this.graphOptions, this.config.Node,
this.config.Edge);
this.labels = new $Hypertree.Label[canvasConfig.Label.type](this);
this.fx = new $Hypertree.Plot(this, $Hypertree);
this.op = new $Hypertree.Op(this);
this.json = null;
this.root = null;
this.busy = false;
// initialize extras
this.initializeExtras();
},
/*
createLevelDistanceFunc
Returns the levelDistance function used for calculating a node distance
to its origin. This function returns a function that is computed
lib/Devel/SizeMe/Graph/static/jit.js view on Meta::CPAN
(start code js)
ht.move({ x: 0, y: 0.7 }, {
hideLabels: false
});
(end code)
*/
move: function(pos, opt) {
var versor = $C(pos.x, pos.y);
if (this.busy === false && versor.norm() < 1) {
this.busy = true;
var root = this.graph.getClosestNodeToPos(versor), that = this;
this.graph.computeLevels(root.id, 0);
this.controller.onBeforeCompute(root);
opt = $.merge( {
onComplete: $.empty
}, opt || {});
this.fx.animate($.merge( {
modes: [ 'moebius' ],
hideLabels: true
}, opt, {
onComplete: function() {
that.busy = false;
opt.onComplete();
}
}), versor);
}
}
});
$jit.Hypertree.$extend = true;
(function(Hypertree) {