plotly.js
Version:
The open source javascript graphing library that powers plotly
37 lines (30 loc) • 724 B
JavaScript
module.exports = function flipTree(node, size, opts) {
var tmp;
if(opts.swapXY) {
// swap x0 and y0
tmp = node.x0;
node.x0 = node.y0;
node.y0 = tmp;
// swap x1 and y1
tmp = node.x1;
node.x1 = node.y1;
node.y1 = tmp;
}
if(opts.flipX) {
tmp = node.x0;
node.x0 = size[0] - node.x1;
node.x1 = size[0] - tmp;
}
if(opts.flipY) {
tmp = node.y0;
node.y0 = size[1] - node.y1;
node.y1 = size[1] - tmp;
}
var children = node.children;
if(children) {
for(var i = 0; i < children.length; i++) {
flipTree(children[i], size, opts);
}
}
};
;