Last active
August 29, 2015 14:13
-
-
Save timelyportfolio/b0119a09e67ff1ed0577 to your computer and use it in GitHub Desktop.
ggplot build with hierNetwork from networkD3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#devtools::install_github("timelyportfolio/networkD3@feature/d3.chart.layout") | |
library(networkD3) | |
library(ggplot2) | |
# recursive approach! http://stackoverflow.com/questions/12818864/how-to-write-to-json-with-children-from-r | |
makeList <- function(x) { | |
idx <- is.na(x[,2]) | |
if (ncol(x) > 2 && sum(idx) != nrow(x)){ | |
listSplit <- split(x[-1], x[1], drop=T) | |
lapply(names(listSplit), function(y){list(name = y, children = makeList(listSplit[[y]]))}) | |
} else { | |
nms <- x[,1] | |
lapply(seq_along(nms), function(y){list(name = nms[y], value = x[,"value"][y])}) | |
} | |
} | |
# thanks Jeroen http://stackoverflow.com/questions/19734412/flatten-nested-list-into-1-deep-list | |
renquote <- function(l) if (is.list(l)) lapply(l, renquote) else enquote(l) | |
gg2tree <- function(gg) { | |
la <- lapply(unlist(renquote(gg)), eval) | |
# capture the output of the list values as one long character string | |
vals <- lapply(la, function(x) paste(utils::capture.output(x), collapse = "<br>")) | |
#names(vals) <- gsub("\\.", "_", names(vals)) | |
# preallocate matrix | |
lvls <- strsplit(names(vals), "\\.") | |
d <- max(sapply(lvls, length)) #maximum depth of the list | |
m <- matrix(NA, nrow = length(lvls), ncol = d) | |
for (i in seq_len(d)) m[,i] <- sapply(lvls, function(x) x[i]) | |
m <- data.frame(m, value = as.character(vals)) | |
list(name = "ggplot", children = makeList(m)) | |
} | |
ggT = gg2tree(ggplot_build(ggplot(aes(x=x,y=x),data=data.frame(x=1:10))+geom_line())) | |
library(htmltools) | |
html_print(tagList( | |
lapply( | |
c("tree.cartesian" | |
,"tree.radial" | |
,"cluster.cartesian" | |
,"cluster.radial" | |
) | |
,function(chartType){ | |
hierNetwork( ggT, type = chartType, zoomable = T, collapsible = T ) | |
} | |
) | |
)) -> htmlFile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*! d3.chart.layout - v0.1.1 | |
* https://github.com/bansaghi/d3.chart.layout/ | |
* | |
* Copyright (c) 2014 Anna Bansaghi | |
* License under the BSD license. | |
*/ | |
d3.chart("hierarchy", { | |
initialize: function() { | |
this.d3 = {}; | |
this.layers = {}; | |
this.base.attr("width", this.base.node().parentNode.clientWidth); | |
this.base.attr("height", this.base.node().parentNode.clientHeight); | |
this.d3.zoom = d3.behavior.zoom(); | |
this.layers.base = this.base.append("g"); | |
this.name(this._name || "name"); | |
this.value(this._value || "value"); | |
this.duration(this._duration || 750); | |
}, | |
transform: function(root) { | |
return root; | |
}, | |
name: function(_) { | |
if (!arguments.length) { | |
return this._name; | |
} | |
this._name = _; | |
this.trigger("change:name"); | |
if (this.root) { | |
this.draw(this.root); | |
} | |
return this; | |
}, | |
value: function(_) { | |
if (!arguments.length) { | |
return this._value; | |
} | |
this._value = _; | |
this.trigger("change:value"); | |
if (this.root) { | |
this.draw(this.root); | |
} | |
return this; | |
}, | |
duration: function(_) { | |
if (!arguments.length) { | |
return this._duration; | |
} | |
this._duration = _; | |
this.trigger("change:duration"); | |
if (this.root) { | |
this.draw(this.root); | |
} | |
return this; | |
}, | |
zoomable: function(_) { | |
var chart = this; | |
var extent = _ || [0, Infinity]; | |
function zoom() { | |
chart.layers.base | |
.attr("transform", "translate(" + d3.event.translate + ")" + " scale(" + d3.event.scale + ")"); | |
} | |
chart.base.call(chart.d3.zoom.scaleExtent(extent).on("zoom", zoom)); | |
return chart; | |
}, | |
}); | |
d3.chart("hierarchy").extend("cluster-tree", { | |
initialize : function() { | |
var chart = this; | |
var counter = 0; | |
chart.radius(chart._radius || 4.5); | |
chart._width = chart.base.attr("width"); | |
chart._height = chart.base.attr("height"); | |
chart.layers.links = chart.layers.base.append("g").classed("links", true); | |
chart.layers.nodes = chart.layers.base.append("g").classed("nodes", true); | |
chart.layer("nodes", chart.layers.nodes, { | |
dataBind: function(data) { | |
return this.selectAll(".node") | |
.data(data, function(d) { return d._id || (d._id = ++counter); }); | |
}, | |
insert: function() { | |
return this.append("g") | |
.classed("node", true); | |
}, | |
events: { | |
"enter": function() { | |
this.append("circle") | |
.attr("r", 0) | |
.style("fill", function(d) { return d._children ? "lightsteelblue" : "#fff"; }); | |
this.append("text") | |
.attr("dy", ".35em") | |
.text(function(d) { return d[chart._name]; }) | |
.style("fill-opacity", 0); | |
// http://stackoverflow.com/questions/1067464/need-to-cancel-click-mouseup-events-when-double-click-event-detected/1067484#1067484 | |
this.on("click", function(event) { | |
var that = this; | |
setTimeout(function() { | |
var dblclick = parseInt(that.getAttribute("data-double"), 10); | |
if (dblclick > 0) { | |
that.setAttribute("data-double", dblclick-1); | |
} else { | |
chart.trigger("singleClick", event); | |
} | |
}, 300); | |
d3.event.stopPropagation(); | |
}).on("dblclick", function(event) { | |
this.setAttribute("data-double", 2); | |
chart.trigger("doubleClick", event); | |
d3.event.stopPropagation(); | |
}); | |
}, | |
"merge:transition": function() { | |
this.select("circle") | |
.attr("r", chart._radius) | |
.style("stroke", function(d) { return d.path ? "brown" : "steelblue"; }) | |
.style("fill", function(d) { return d.path && ! d.parent.path ? "#E2A76F" | |
: d._children ? "lightsteelblue" : "#fff"; }); | |
this.select("text") | |
.style("fill-opacity", 1); | |
}, | |
"exit:transition": function() { | |
this.duration(chart._duration) | |
.remove(); | |
this.select("circle") | |
.attr("r", 0); | |
this.select("text") | |
.style("fill-opacity", 0); | |
}, | |
} | |
}); | |
chart.layer("links", chart.layers.links, { | |
dataBind: function(data) { | |
return this.selectAll(".link") | |
.data(chart.d3.layout.links(data), function(d) { return d.target._id; }); | |
}, | |
insert: function() { | |
return this.append("path") | |
.classed("link", true); | |
}, | |
events: { | |
"enter": function() { | |
this | |
.attr("d", function(d) { | |
var o = { x: chart.source.x0, y: chart.source.y0 }; | |
return chart.d3.diagonal({ source: o, target: o }); | |
}); | |
}, | |
"merge:transition": function() { | |
this.duration(chart._duration) | |
.attr("d", chart.d3.diagonal) | |
.attr("stroke", function(d) { return d.source.path && d.target.path ? "#dd7b7b" : "#ccc"; }) | |
.style("stroke-width", function(d) { return d.path ? 1 : 1.5; }); | |
}, | |
"exit:transition": function() { | |
this.duration(chart._duration) | |
.attr("d", function(d) { | |
var o = { x: chart.source.x, y: chart.source.y }; | |
return chart.d3.diagonal({ source: o, target: o }); | |
}) | |
.remove(); | |
}, | |
}, | |
}); | |
}, | |
radius: function(_) { | |
if (!arguments.length) { | |
return this._radius; | |
} | |
this._radius = _; | |
this.trigger("change:radius"); | |
if (this.root) { | |
this.draw(this.root); | |
} | |
return this; | |
}, | |
collapsible: function() { | |
var chart = this; | |
chart.once("collapse:init", function() { | |
//chart.root.children.forEach(collapse); | |
}); | |
chart.on("singleClick", function(d) { | |
d = toggle(d); | |
chart.trigger("transform:stash"); | |
chart.draw(d); | |
}); | |
function toggle(d) { | |
if (d.children) { | |
d._children = d.children; | |
d.children = null; | |
} else if (d._children) { | |
d.children = d._children; | |
d._children = null; | |
} | |
return d; | |
} | |
function collapse(d) { | |
if (d.children) { | |
d._children = d.children; | |
d._children.forEach(collapse); | |
d.children = null; | |
} | |
} | |
return this; | |
}, | |
}); | |
d3.chart("cluster-tree").extend("cluster-tree.cartesian", { | |
initialize : function() { | |
var chart = this; | |
chart.margin(chart._margin || {}); | |
chart.d3.diagonal = d3.svg.diagonal().projection(function(d) { return [d.y, d.x]; }); | |
chart.layers.nodes.on("enter", function() { | |
this | |
.attr("transform", function(d) { return "translate(" + chart.source.y0 + "," + chart.source.x0 + ")"; }); | |
this.select("text") | |
.attr("x", function(d) { return d.children || d._children ? -10 : 10; }) | |
.attr("text-anchor", function(d) { return d.children || d._children ? "end" : "start"; }); | |
}); | |
chart.layers.nodes.on("merge:transition", function() { | |
this.duration(chart._duration) | |
.attr("transform", function(d) { return "translate(" + d.y + "," + d.x + ")"; }); | |
}); | |
chart.layers.nodes.on("exit:transition", function() { | |
this | |
.attr("transform", function(d) { return "translate(" + chart.source.y + "," + chart.source.x + ")"; }); | |
}); | |
chart.on("change:margin", function() { | |
chart._width = chart.base.attr("width") - chart._margin.left - chart._margin.right; | |
chart._height = chart.base.attr("height") - chart._margin.top - chart._margin.bottom; | |
chart.base.attr("transform", "translate(" + chart._margin.left + "," + chart._margin.top + ")"); | |
}); | |
}, | |
transform: function(root) { | |
var chart = this, | |
nodes; | |
chart.source = root; | |
if ( ! chart.root) { | |
chart.root = root; | |
chart.root.x0 = chart._height / 2; | |
chart.root.y0 = 0; | |
nodes = chart.d3.layout | |
.size([chart._height, chart._width]) | |
.nodes(chart.root); // workaround for getting correct chart.root to transform method in hierarchy.js | |
chart.trigger("collapse:init"); | |
} | |
nodes = chart.d3.layout | |
//.size([chart._height, chart._width]) | |
.nodes(chart.root).reverse(); | |
// nodes.forEach(function(d) { d.y = d.depth * 180; }); | |
chart.on("transform:stash", function() { | |
nodes.forEach(function(d) { | |
d.x0 = d.x; | |
d.y0 = d.y; | |
}); | |
}); | |
return nodes; | |
}, | |
margin: function(_) { | |
if (!arguments.length) { | |
return this._margin; | |
} | |
["top", "right", "bottom", "left"].forEach(function(dimension) { | |
if (dimension in _) { | |
this[dimension] = _[dimension]; | |
} | |
}, this._margin = { top: 0, right: 0, bottom: 0, left: 0 }); | |
this.trigger("change:margin"); | |
if (this.root) { | |
this.draw(this.root); | |
} | |
return this; | |
}, | |
}); | |
d3.chart("cluster-tree").extend("cluster-tree.radial", { | |
initialize : function() { | |
var chart = this; | |
chart.diameter(chart._diameter || Math.min(chart._width, chart._height)); | |
chart.d3.diagonal = d3.svg.diagonal.radial().projection(function(d) { return [d.y, d.x / 180 * Math.PI]; }); | |
chart.d3.zoom.translate([chart._diameter / 2, chart._diameter / 2]); | |
chart.layers.base | |
.attr("transform", "translate(" + chart._diameter / 2 + "," + chart._diameter / 2 + ")"); | |
chart.layers.nodes.on("enter", function() { | |
this | |
.attr("transform", function(d) { return "rotate(" + (chart.source.x0 - 90) + ")translate(" + chart.source.y0 + ")"; }); | |
this.select("text") | |
.attr("text-anchor", function(d) { return d.x < 180 ? "start" : "end"; }) | |
.attr("transform", function(d) { return d.x < 180 ? "translate(8)" : "rotate(180)translate(-8)"; }); | |
}); | |
chart.layers.nodes.on("merge:transition", function() { | |
this.duration(chart._duration) | |
.attr("transform", function(d) { return "rotate(" + (d.x - 90) + ")translate(" + d.y + ")"; }); | |
}); | |
chart.layers.nodes.on("exit:transition", function() { | |
this | |
.attr("transform", function(d) { return "rotate(" + (chart.source.x - 90) + ")translate(" + chart.source.y + ")"; }); | |
}); | |
}, | |
transform: function(root) { | |
var chart = this, | |
nodes; | |
chart.source = root; | |
if ( ! chart.root) { | |
chart.root = root; | |
chart.root.x0 = 360; | |
chart.root.y0 = 0; | |
nodes = chart.d3.layout | |
.size([360, chart._diameter / 4]) | |
.separation(function(a, b) { if (a.depth === 0) { return 1; } else { return (a.parent == b.parent ? 1 : 2) / a.depth; }}) // workaround | |
.nodes(chart.root); | |
chart.trigger("collapse:init"); | |
} | |
nodes = chart.d3.layout.nodes(chart.root).reverse(); | |
//nodes.forEach(function(d) { d.y = d.depth * 180; }); | |
chart.on("transform:stash", function() { | |
nodes.forEach(function(d) { | |
d.x0 = d.x; | |
d.y0 = d.y; | |
}); | |
}); | |
return nodes; | |
}, | |
diameter: function(_) { | |
if (!arguments.length) { | |
return this._diameter; | |
} | |
this._diameter = _; | |
this.trigger("change:diameter"); | |
if (this.root) { | |
this.draw(this.root); | |
} | |
return this; | |
}, | |
}); | |
d3.chart("cluster-tree.cartesian").extend("cluster.cartesian", { | |
initialize : function() { | |
this.d3.layout = d3.layout.cluster(); | |
}, | |
}); | |
d3.chart("cluster-tree.radial").extend("cluster.radial", { | |
initialize : function() { | |
this.d3.layout = d3.layout.cluster(); | |
}, | |
}); | |
d3.chart("hierarchy").extend("pack.flattened", { | |
initialize : function() { | |
var chart = this; | |
chart.d3.layout = d3.layout.pack(); | |
chart._width = chart.base.attr("width"); | |
chart._height = chart.base.attr("height"); | |
chart.flatten(chart._flatten || null); | |
chart.formats(chart._formats || {}); | |
chart.diameter(chart._diameter || Math.min(chart._width, chart._height)); | |
chart.d3.zoom.translate([(chart._width - chart._diameter) / 2, (chart._height - chart._diameter) / 2]); | |
chart.layers.base | |
.attr("transform", "translate(" + (chart._width - chart._diameter) / 2 + "," + (chart._height - chart._diameter) / 2 + ")"); | |
chart.layer("base", chart.layers.base, { | |
dataBind: function(data) { | |
return this.selectAll(".node") | |
.data(data.filter(function(d) { return ! d.children; })); | |
}, | |
insert: function() { | |
return this.append("g"); | |
}, | |
events: { | |
"enter": function() { | |
this.attr("transform", function(d) { return "translate(" + d.x + "," + d.y + ")"; }); | |
this.append("circle") | |
.attr("r", function(d) { return d.r; }) | |
.style("stroke", "#aaa") | |
.style("fill", chart._formats.fill); | |
this.append("text") | |
.attr("dy", ".3em") | |
.style("text-anchor", "middle") | |
.text(function(d) { return d[chart._name].substring(0, d.r / 3); }); | |
this.append("title") | |
.text(chart._formats.title); | |
this.on("click", function(event) { | |
var that = this; | |
setTimeout(function() { | |
var dblclick = parseInt(that.getAttribute("data-double"), 10); | |
if (dblclick > 0) { | |
that.setAttribute("data-double", dblclick-1); | |
} else { | |
chart.trigger("singleClick", event); | |
} | |
}, 300); | |
d3.event.stopPropagation(); | |
}).on("dblclick", function(event) { | |
this.setAttribute("data-double", 2); | |
chart.trigger("doubleClick", event); | |
d3.event.stopPropagation(); | |
}); | |
}, | |
} | |
}); | |
chart.on("change:diameter", function() { | |
chart.layers.base | |
.attr("transform", "translate(" + (chart._width - chart._diameter) / 2 + "," + (chart._height - chart._diameter) / 2 + ")"); | |
}); | |
}, | |
transform: function(root) { | |
var chart = this; | |
chart.root = root; | |
return chart.d3.layout | |
.size([chart._diameter, chart._diameter]) | |
.sort(null) | |
.padding(1.5) | |
.value(function(d) { return d[chart._value]; }) | |
.nodes(chart._flatten ? chart._flatten(root) : root); | |
}, | |
diameter: function(_) { | |
if (!arguments.length) { | |
return this._diameter; | |
} | |
this._diameter = _ - 10; | |
this.trigger("change:diameter"); | |
if (this.root) { | |
this.draw(this.root); | |
} | |
return this; | |
}, | |
flatten: function(_) { | |
if (!arguments.length) { | |
return this._flatten; | |
} | |
this._flatten = _; | |
this.trigger("change:flatten"); | |
if (this.root) { | |
this.draw(this.root); | |
} | |
return this; | |
}, | |
formats: function(_) { | |
if (!arguments.length) { | |
return this._formats; | |
} | |
var chart = this; | |
var color = d3.scale.category20c(); | |
["title", "fill"].forEach(function(format) { | |
if (format in _) { | |
this[format] = d3.functor(_[format]); | |
} | |
}, this._formats = { | |
title : function(d) { return d[chart._value]; }, | |
fill : function(d) { return color(d[chart._name]); } | |
} | |
); | |
this.trigger("change:formats"); | |
if (this.root) { | |
this.draw(this.root); | |
} | |
return this; | |
}, | |
}); | |
d3.chart("hierarchy").extend("pack.nested", { | |
initialize : function() { | |
var chart = this; | |
chart.d3.layout = d3.layout.pack(); | |
chart._width = chart.base.attr("width"); | |
chart._height = chart.base.attr("height"); | |
chart.diameter(chart._diameter || Math.min(chart._width, chart._height)); | |
chart.d3.zoom.translate([(chart._width - chart._diameter) / 2, (chart._height - chart._diameter) / 2]); | |
chart.layers.base | |
.attr("transform", "translate(" + (chart._width - chart._diameter) / 2 + "," + (chart._height - chart._diameter) / 2 + ")"); | |
chart.layer("base", chart.layers.base, { | |
dataBind: function(data) { | |
return this.selectAll(".node").data(data); | |
}, | |
insert: function() { | |
return this.append("g"); | |
}, | |
events: { | |
enter: function() { | |
this.attr("transform", function(d) { return "translate(" + d.x + "," + d.y + ")"; }); | |
this.append("circle") | |
.attr("r", function(d) { return d.r; }); | |
this.append("text") | |
.attr("dy", ".3em") | |
.style("text-anchor", "middle"); | |
this.on("click", function(event) { | |
var that = this; | |
setTimeout(function() { | |
var dblclick = parseInt(that.getAttribute("data-double"), 10); | |
if (dblclick > 0) { | |
that.setAttribute("data-double", dblclick-1); | |
} else { | |
chart.trigger("singleClick", event); | |
} | |
}, 300); | |
d3.event.stopPropagation(); | |
}).on("dblclick", function(event) { | |
this.setAttribute("data-double", 2); | |
chart.trigger("doubleClick", event); | |
d3.event.stopPropagation(); | |
}); | |
}, | |
merge: function() { | |
this.attr("class", function(d) { return d.children ? "node parent" : "node child"; }); | |
this.select("text") | |
.style("opacity", function(d) { return d.r > 20 ? 1 : 0; }) | |
.text(function(d) { return d[chart._name]; }); | |
}, | |
} | |
}); | |
chart.on("change:diameter", function() { | |
chart.layers.base | |
.attr("transform", "translate(" + (chart._width - chart._diameter) / 2 + "," + (chart._height - chart._diameter) / 2 + ")"); | |
}); | |
}, | |
transform: function(root) { | |
var chart = this; | |
chart.root = root; | |
return chart.d3.layout | |
.size([chart._diameter, chart._diameter]) | |
.value(function(d) { return d[chart._value]; }) | |
.nodes(root); | |
}, | |
diameter: function(_) { | |
if (!arguments.length) { | |
return this._diameter; | |
} | |
this._diameter = _ - 10; | |
this.trigger("change:diameter"); | |
if (this.root) { | |
this.draw(this.root); | |
} | |
return this; | |
}, | |
collapsible: function() { | |
var chart = this; | |
var node, | |
x = d3.scale.linear().range([0, chart._diameter]), | |
y = d3.scale.linear().range([0, chart._diameter]); | |
chart.layers.base.on("merge", function() { | |
node = chart.root; | |
chart.on("singleClick", function(d) { collapse(node == d ? chart.root : d); }); | |
}); | |
chart.base.on("click", function() { collapse(chart.root); }); | |
// d3.select(window).on("click", function() { collapse(chart.root); }); | |
function collapse(d) { | |
var k = chart._diameter / d.r / 2; | |
x.domain([d.x - d.r, d.x + d.r]); | |
y.domain([d.y - d.r, d.y + d.r]); | |
var t = chart.layers.base.transition() | |
.duration(chart._duration); | |
t.selectAll(".node") | |
.attr("transform", function(d) { return "translate(" + x(d.x) + "," + y(d.y) + ")"; }); | |
t.selectAll("circle") | |
.attr("r", function(d) { return k * d.r; }); | |
t.selectAll("text") | |
.style("opacity", function(d) { return k * d.r > 20 ? 1 : 0; }); | |
node = d; | |
} | |
return this; | |
}, | |
}); | |
d3.chart("hierarchy").extend("partition.arc", { | |
initialize : function() { | |
var chart = this; | |
chart.d3.layout = d3.layout.partition(); | |
chart._width = chart.base.attr("width"); | |
chart._height = chart.base.attr("height"); | |
chart.diameter(chart._diameter || Math.min(chart._width, chart._height)); | |
chart.d3.color = d3.scale.category20c(); | |
chart.d3.x = d3.scale.linear().range([0, 2 * Math.PI]); | |
chart.d3.y = d3.scale.sqrt().range([0, chart._diameter / 2]); | |
chart.d3.arc = d3.svg.arc() | |
.startAngle(function(d) { return Math.max(0, Math.min(2 * Math.PI, chart.d3.x(d.x))); }) | |
.endAngle(function(d) { return Math.max(0, Math.min(2 * Math.PI, chart.d3.x(d.x + d.dx))); }) | |
.innerRadius(function(d) { return Math.max(0, chart.d3.y(d.y)); }) | |
.outerRadius(function(d) { return Math.max(0, chart.d3.y(d.y + d.dy)); }); | |
chart.d3.zoom.translate([chart.base.attr("width") / 2, chart.base.attr("height") / 2]); | |
chart.layers.base | |
.attr("transform", "translate(" + chart.base.attr("width") / 2 + "," + chart.base.attr("height") / 2 + ")"); | |
chart.layer("base", chart.layers.base, { | |
dataBind: function(data) { | |
return this.selectAll("path") | |
.data(data); | |
}, | |
insert: function() { | |
return this.append("path"); | |
}, | |
events: { | |
enter: function() { | |
this.attr("d", chart.d3.arc) | |
.style("fill", function(d) { return chart.d3.color((d.children ? d : d.parent)[chart._name]); }); | |
this.on("click", function(event) { | |
var that = this; | |
setTimeout(function() { | |
var dblclick = parseInt(that.getAttribute("data-double"), 10); | |
if (dblclick > 0) { | |
that.setAttribute("data-double", dblclick-1); | |
} else { | |
chart.trigger("singleClick", event); | |
} | |
}, 300); | |
d3.event.stopPropagation(); | |
}).on("dblclick", function(event) { | |
this.setAttribute("data-double", 2); | |
chart.trigger("doubleClick", event); | |
d3.event.stopPropagation(); | |
}); | |
} | |
} | |
}); | |
chart.on("change:radius", function() { | |
chart.layers.paths | |
.attr("transform", "translate(" + chart.base.attr("width") / 2 + "," + chart.base.attr("height") / 2 + ")"); | |
chart.d3.y = d3.scale.sqrt().range([0, chart._diameter / 2]); | |
}); | |
}, | |
transform: function(root) { | |
var chart = this; | |
chart.root = root; | |
return chart.d3.layout | |
.value(function(d) { return d[chart._value]; }) | |
.nodes(root); | |
}, | |
diameter: function(_) { | |
if (!arguments.length) { | |
return this._diameter; | |
} | |
this._diameter = _ - 10; | |
this.trigger("change:radius"); | |
if (this.root) { | |
this.draw(this.root); | |
} | |
return this; | |
}, | |
collapsible: function() { | |
var chart = this; | |
chart.layers.base.on("merge", function() { | |
var path = this; | |
chart.on("singleClick", function(d) { | |
path.transition() | |
.duration(chart._duration) | |
.attrTween("d", arcTween(d)); | |
}); | |
}); | |
function arcTween(d) { | |
var xd = d3.interpolate(chart.d3.x.domain(), [d.x, d.x + d.dx]), | |
yd = d3.interpolate(chart.d3.y.domain(), [d.y, 1]), | |
yr = d3.interpolate(chart.d3.y.range(), [d.y ? 20 : 0, chart._diameter / 2]); | |
return function(d, i) { | |
return i ? function(t) { return chart.d3.arc(d); } | |
: function(t) { chart.d3.x.domain(xd(t)); chart.d3.y.domain(yd(t)).range(yr(t)); return chart.d3.arc(d); }; | |
}; | |
} | |
return this; | |
}, | |
}); | |
d3.chart("hierarchy").extend("partition.rectangle", { | |
initialize : function() { | |
var chart = this; | |
chart.d3.layout = d3.layout.partition(); | |
chart._width = chart.base.attr("width"); | |
chart._height = chart.base.attr("height"); | |
var x = d3.scale.linear().range([0, chart._width]), | |
y = d3.scale.linear().range([0, chart._height]); | |
chart.d3.transform = function(d, ky) { return "translate(8," + d.dx * ky / 2 + ")"; }; | |
chart.layer("base", chart.layers.base, { | |
dataBind: function(data) { | |
return this.selectAll(".partition") | |
.data(data); | |
}, | |
insert: function() { | |
return this.append("g") | |
.classed("partition", true) | |
.attr("transform", function(d) { return "translate(" + x(d.y) + "," + y(d.x) + ")"; }); | |
}, | |
events: { | |
enter: function() { | |
var kx = chart._width / chart.root.dx, | |
ky = chart._height / 1; | |
this.append("rect") | |
.attr("class", function(d) { return d.children ? "parent" : "child"; }) | |
.attr("width", chart.root.dy * kx) | |
.attr("height", function(d) { return d.dx * ky; }); | |
this.append("text") | |
.attr("transform", function(d) { return chart.d3.transform(d, ky); }) | |
.attr("dy", ".35em") | |
.style("opacity", function(d) { return d.dx * ky > 12 ? 1 : 0; }) | |
.text(function(d) { return d[chart._name]; }); | |
this.on("click", function(event) { | |
var that = this; | |
setTimeout(function() { | |
var dblclick = parseInt(that.getAttribute("data-double"), 10); | |
if (dblclick > 0) { | |
that.setAttribute("data-double", dblclick-1); | |
} else { | |
chart.trigger("singleClick", event); | |
} | |
}, 300); | |
d3.event.stopPropagation(); | |
}).on("dblclick", function(event) { | |
this.setAttribute("data-double", 2); | |
chart.trigger("doubleClick", event); | |
d3.event.stopPropagation(); | |
}); | |
} | |
} | |
}); | |
}, | |
transform: function(root) { | |
var chart = this; | |
chart.root = root; | |
return chart.d3.layout | |
.value(function(d) { return d[chart._value]; }) | |
.nodes(root); | |
}, | |
collapsible: function() { | |
var chart = this; | |
var node, | |
x = d3.scale.linear(), | |
y = d3.scale.linear().range([0, chart._height]); | |
chart.layers.base.on("merge", function() { | |
node = chart.root; | |
chart.on("singleClick", function(d) { collapse(node == d ? chart.root : d); }); | |
}); | |
chart.base.on("click", function() { collapse(chart.root); }); | |
function collapse(d) { | |
var kx = (d.y ? chart._width - 40 : chart._width) / (1 - d.y), | |
ky = chart._height / d.dx; | |
x.domain([d.y, 1]).range([d.y ? 40 : 0, chart._width]); | |
y.domain([d.x, d.x + d.dx]); | |
var t = chart.layers.base.transition() | |
.duration(chart._duration); | |
t.selectAll(".partition") | |
.attr("transform", function(d) { return "translate(" + x(d.y) + "," + y(d.x) + ")"; }); | |
t.selectAll("rect") | |
.attr("width", d.dy * kx) | |
.attr("height", function(d) { return d.dx * ky; }); | |
t.selectAll("text") | |
.attr("transform", function(d) { return chart.d3.transform(d, ky); }) | |
.style("opacity", function(d) { return d.dx * ky > 12 ? 1 : 0; }); | |
node = d; | |
} | |
return this; | |
}, | |
}); | |
d3.chart("cluster-tree.cartesian").extend("tree.cartesian", { | |
initialize : function() { | |
this.d3.layout = d3.layout.tree(); | |
}, | |
}); | |
d3.chart("cluster-tree.radial").extend("tree.radial", { | |
initialize : function() { | |
this.d3.layout = d3.layout.tree(); | |
} | |
}); | |
d3.chart("hierarchy").extend("treemap", { | |
initialize : function() { | |
var chart = this; | |
chart.d3.layout = d3.layout.treemap(); | |
chart._width = chart.base.attr("width"); | |
chart._height = chart.base.attr("height"); | |
var color = d3.scale.category20c(); | |
chart.layer("base", chart.layers.base, { | |
dataBind: function(data) { | |
return this.selectAll(".cell") | |
.data(data); | |
}, | |
insert: function() { | |
return this.append("g") | |
.classed("cell", true) | |
.attr("transform", function(d) { return "translate(" + d.x + "," + d.y + ")"; }); | |
}, | |
events: { | |
enter: function() { | |
this.append("rect") | |
.attr("width", function(d) { return d.dx; }) | |
.attr("height", function(d) { return d.dy; }) | |
.attr("fill", function(d) { return d.parent ? color(d.parent[chart._name]) : null; }); | |
this.append("text") | |
.attr("x", function(d) { return d.dx / 2; }) | |
.attr("y", function(d) { return d.dy / 2; }) | |
.attr("dy", ".35em") | |
.attr("text-anchor", "middle") | |
.text(function(d) { return d.children ? null : d[chart._name]; }) // order is matter! getComputedTextLength | |
.style("opacity", function(d) { d.w = this.getComputedTextLength(); return d.dx > d.w ? 1 : 0; }); | |
this.on("click", function(event) { | |
var that = this; | |
setTimeout(function() { | |
var dblclick = parseInt(that.getAttribute("data-double"), 10); | |
if (dblclick > 0) { | |
that.setAttribute("data-double", dblclick-1); | |
} else { | |
chart.trigger("singleClick", event); | |
} | |
}, 300); | |
d3.event.stopPropagation(); | |
}).on("dblclick", function(event) { | |
this.setAttribute("data-double", 2); | |
chart.trigger("doubleClick", event); | |
d3.event.stopPropagation(); | |
}); | |
}, | |
} | |
}); | |
}, | |
transform: function(root) { | |
var chart = this; | |
chart.root = root; | |
return chart.d3.layout | |
.round(false) | |
.size([chart._width, chart._height]) | |
.sticky(true) | |
.value(function(d) { return d[chart._value]; }) | |
.nodes(root); | |
}, | |
collapsible: function() { | |
var chart = this; | |
var node, | |
x = d3.scale.linear().range([0, chart._width]), | |
y = d3.scale.linear().range([0, chart._height]); | |
chart.layers.base.on("merge", function() { | |
node = chart.root; | |
chart.on("singleClick", function(d) { collapse(node == d.parent ? chart.root : d.parent); }); | |
}); | |
chart.base.on("click", function() { collapse(chart.root); }); | |
function collapse(d) { | |
var kx = chart._width / d.dx, | |
ky = chart._height / d.dy; | |
x.domain([d.x, d.x + d.dx]); | |
y.domain([d.y, d.y + d.dy]); | |
var t = chart.layers.base.transition() | |
.duration(chart._duration); | |
t.selectAll(".cell") | |
.attr("transform", function(d) { return "translate(" + x(d.x) + "," + y(d.y) + ")"; }); | |
t.selectAll("rect") | |
.attr("width", function(d) { return kx * d.dx; }) | |
.attr("height", function(d) { return ky * d.dy; }); | |
t.selectAll("text") | |
.attr("x", function(d) { return kx * d.dx / 2; }) | |
.attr("y", function(d) { return ky * d.dy / 2; }) | |
.style("opacity", function(d) { return kx * d.dx > d.w ? 1 : 0; }); | |
node = d; | |
} | |
return this; | |
}, | |
}); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*! d3.chart - v0.2.1 | |
* License: MIT Expat | |
* Date: 2014-06-24 | |
*/ | |
(function(t){"use strict";function e(t){var e,r,n,i;if(!t)return t;for(r=arguments.length,e=1;r>e;e++)if(n=arguments[e])for(i in n)t[i]=n[i];return t}var r=t.d3,n=Object.hasOwnProperty,i=function(t,e){if(!t)throw Error("[d3.chart] "+e)};i(r,"d3.js is required"),i("string"==typeof r.version&&r.version.match(/^3/),"d3.js version 3 is required");var a=/^(enter|update|merge|exit)(:transition)?$/,s=function(t){i(t,"Layers must be initialized with a base."),this._base=t,this._handlers={}};s.prototype.dataBind=function(){i(!1,"Layers must specify a `dataBind` method.")},s.prototype.insert=function(){i(!1,"Layers must specify an `insert` method.")},s.prototype.on=function(t,e,r){return r=r||{},i(a.test(t),"Unrecognized lifecycle event name specified to `Layer#on`: '"+t+"'."),t in this._handlers||(this._handlers[t]=[]),this._handlers[t].push({callback:e,chart:r.chart||null}),this._base},s.prototype.off=function(t,e){var r,n=this._handlers[t];if(i(a.test(t),"Unrecognized lifecycle event name specified to `Layer#off`: '"+t+"'."),!n)return this._base;if(1===arguments.length)return n.length=0,this._base;for(r=n.length-1;r>-1;--r)n[r].callback===e&&n.splice(r,1);return this._base},s.prototype.draw=function(t){var e,n,a,s,o,h,c,l;e=this.dataBind.call(this._base,t),i(e&&e.call===r.selection.prototype.call,"Invalid selection defined by `Layer#dataBind` method."),i(e.enter,"Layer selection not properly bound."),n=e.enter(),n._chart=this._base._chart,a=[{name:"update",selection:e},{name:"enter",selection:this.insert.bind(n)},{name:"merge",selection:e},{name:"exit",selection:e.exit.bind(e)}];for(var u=0,p=a.length;p>u;++u)if(h=a[u].name,s=a[u].selection,"function"==typeof s&&(s=s()),!s.empty()){if(i(s&&s.call===r.selection.prototype.call,"Invalid selection defined for '"+h+"' lifecycle event."),o=this._handlers[h])for(c=0,l=o.length;l>c;++c)s._chart=o[c].chart||this._base._chart,s.call(o[c].callback);if(o=this._handlers[h+":transition"],o&&o.length)for(s=s.transition(),c=0,l=o.length;l>c;++c)s._chart=o[c].chart||this._base._chart,s.call(o[c].callback)}},r.selection.prototype.layer=function(t){var e,r=new s(this);if(r.dataBind=t.dataBind,r.insert=t.insert,"events"in t)for(e in t.events)r.on(e,t.events[e]);return this.on=function(){return r.on.apply(r,arguments)},this.off=function(){return r.off.apply(r,arguments)},this.draw=function(){return r.draw.apply(r,arguments)},this};var o=function(t,e){var r=this.constructor,i=r.__super__;i&&o.call(i,t,e),n.call(r.prototype,"initialize")&&this.initialize.apply(t,e)},h=function(t,e){var r=this.constructor,i=r.__super__;return this===t&&n.call(this,"transform")&&(e=this.transform(e)),n.call(r.prototype,"transform")&&(e=r.prototype.transform.call(t,e)),i&&(e=h.call(i,t,e)),e},c=function(t,e){this.base=t,this._layers={},this._attached={},this._events={},e&&e.transform&&(this.transform=e.transform),o.call(this,this,[e])};c.prototype.initialize=function(){},c.prototype.unlayer=function(t){var e=this.layer(t);return delete this._layers[t],delete e._chart,e},c.prototype.layer=function(t,e,r){var n;if(1===arguments.length)return this._layers[t];if(2===arguments.length){if("function"==typeof e.draw)return e._chart=this,this._layers[t]=e,this._layers[t];i(!1,"When reattaching a layer, the second argument must be a d3.chart layer")}return n=e.layer(r),this._layers[t]=n,e._chart=this,n},c.prototype.attach=function(t,e){return 1===arguments.length?this._attached[t]:(this._attached[t]=e,e)},c.prototype.draw=function(t){var e,r,n;t=h.call(this,this,t);for(e in this._layers)this._layers[e].draw(t);for(r in this._attached)n=this.demux?this.demux(r,t):t,this._attached[r].draw(n)},c.prototype.on=function(t,e,r){var n=this._events[t]||(this._events[t]=[]);return n.push({callback:e,context:r||this,_chart:this}),this},c.prototype.once=function(t,e,r){var n=this,i=function(){n.off(t,i),e.apply(this,arguments)};return this.on(t,i,r)},c.prototype.off=function(t,e,r){var n,i,a,s,o,h;if(0===arguments.length){for(t in this._events)this._events[t].length=0;return this}if(1===arguments.length)return a=this._events[t],a&&(a.length=0),this;for(n=t?[t]:Object.keys(this._events),o=0;n.length>o;o++)for(i=n[o],a=this._events[i],h=a.length;h--;)s=a[h],(e&&e===s.callback||r&&r===s.context)&&a.splice(h,1);return this},c.prototype.trigger=function(t){var e,r,n=Array.prototype.slice.call(arguments,1),i=this._events[t];if(void 0!==i)for(e=0;i.length>e;e++)r=i[e],r.callback.apply(r.context,n);return this},c.extend=function(t,r,i){var a,s=this;a=r&&n.call(r,"constructor")?r.constructor:function(){return s.apply(this,arguments)},e(a,s,i);var o=function(){this.constructor=a};return o.prototype=s.prototype,a.prototype=new o,r&&e(a.prototype,r),a.__super__=s.prototype,c[t]=a,a},r.chart=function(t){return 0===arguments.length?c:1===arguments.length?c[t]:c.extend.apply(c,arguments)},r.selection.prototype.chart=function(t,e){if(0===arguments.length)return this._chart;var r=c[t];return i(r,"No chart registered with name '"+t+"'"),new r(this,e)},r.selection.enter.prototype.chart=function(){return this._chart},r.transition.prototype.chart=r.selection.enter.prototype.chart})(this); | |
//@ sourceMappingURL=d3.chart.min.map |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HTMLWidgets.widget({ | |
name: "hierNetwork", | |
type: "output", | |
initialize: function(el, width, height) { | |
svg = d3.select(el).append("svg") | |
.attr("width", width) | |
.attr("height", height) | |
.append("g") | |
return {}; | |
}, | |
resize: function(el, width, height, tree) { | |
}, | |
renderValue: function(el, x, tree) { | |
// x is a list with two elements, options and root; root must already be a | |
// JSON array with the d3Tree root data | |
// add type of chart without period as class for styling | |
d3.select(el).classed(x.options.type.replace(/\./g, ""),true); | |
var svg = d3.select(el).selectAll("svg"); | |
tree.chart = svg.chart( x.options.type ) | |
.value( x.options.value ) | |
if( typeof x.options.margin !== "undefined" && tree.chart.margin ){ | |
tree.chart.margin( x.options.margin ) | |
} | |
if( typeof x.options.radius !== "undefined" ) { | |
tree.chart.radius( x.options.radius ) | |
} | |
if( typeof x.options.zoomable !== "undefined" && x.options.zoomable && tree.chart.zoomable ){ | |
tree.chart.zoomable([0.1, 5]) | |
} | |
if( typeof x.options.collapsible !== "undefined" && x.options.collapsible && tree.chart.collapsible ) { | |
tree.chart.collapsible() | |
} | |
if( typeof x.options.duration !== "undefined" ){ | |
tree.chart.duration( x.options.duration ) | |
} | |
tree.chart.draw( JSON.parse( x.root ) ); | |
}, | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.hierNetwork .node,.cell { | |
cursor: pointer; | |
} | |
.hierNetwork .node circle { | |
/*fill: #fff; | |
stroke: steelblue;*/ | |
stroke-width: 1.5px; | |
} | |
.hierNetwork path.link { | |
fill: none; | |
/*stroke: #ccc; | |
stroke-width: 1.5px;*/ | |
} | |
.hierNetwork text { | |
pointer-events: none; | |
} | |
.hierNetwork .parent text { | |
fill: #1f77b4; | |
} | |
.hierNetwork circle { | |
fill: #ccc; | |
stroke: #999; | |
} | |
.hierNetwork .parent circle { | |
fill: #1f77b4; | |
fill-opacity: 0.1; | |
stroke: steelblue; | |
} | |
.hierNetwork .parent:hover circle { | |
stroke: #ff7f0e; | |
stroke-width: 0.5px; | |
} | |
.hierNetwork.partitionrectangle rect { | |
stroke: #eee; | |
fill: #aaa; | |
fill-opacity: .8; | |
} | |
.hierNetwork.partitionrectangle rect.parent { | |
cursor: pointer; | |
fill: steelblue; | |
} | |
.hierNetwork.partitionarc path { | |
cursor: pointer; | |
stroke: #fff; | |
fill-rule: evenodd; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
// If window.HTMLWidgets is already defined, then use it; otherwise create a | |
// new object. This allows preceding code to set options that affect the | |
// initialization process (though none currently exist). | |
window.HTMLWidgets = window.HTMLWidgets || {}; | |
// See if we're running in a viewer pane. If not, we're in a web browser. | |
var viewerMode = window.HTMLWidgets.viewerMode = | |
/\bviewer_pane=1\b/.test(window.location); | |
// See if we're running in Shiny mode. If not, it's a static document. | |
// Note that static widgets can appear in both Shiny and static modes, but | |
// obviously, Shiny widgets can only appear in Shiny apps/documents. | |
var shinyMode = window.HTMLWidgets.shinyMode = | |
typeof(window.Shiny) !== "undefined" && !!window.Shiny.outputBindings; | |
// We can't count on jQuery being available, so we implement our own | |
// version if necessary. | |
function querySelectorAll(scope, selector) { | |
if (typeof(jQuery) !== "undefined" && scope instanceof jQuery) { | |
return scope.find(selector); | |
} | |
if (scope.querySelectorAll) { | |
return scope.querySelectorAll(selector); | |
} | |
} | |
function asArray(value) { | |
if (value === null) | |
return []; | |
if ($.isArray(value)) | |
return value; | |
return [value]; | |
} | |
// Implement jQuery's extend | |
function extend(target /*, ... */) { | |
if (arguments.length == 1) { | |
return target; | |
} | |
for (var i = 1; i < arguments.length; i++) { | |
var source = arguments[i]; | |
for (var prop in source) { | |
if (source.hasOwnProperty(prop)) { | |
target[prop] = source[prop]; | |
} | |
} | |
} | |
return target; | |
} | |
// Replaces the specified method with the return value of funcSource. | |
// | |
// Note that funcSource should not BE the new method, it should be a function | |
// that RETURNS the new method. funcSource receives a single argument that is | |
// the overridden method, it can be called from the new method. The overridden | |
// method can be called like a regular function, it has the target permanently | |
// bound to it so "this" will work correctly. | |
function overrideMethod(target, methodName, funcSource) { | |
var superFunc = target[methodName] || function() {}; | |
var superFuncBound = function() { | |
return superFunc.apply(target, arguments); | |
}; | |
target[methodName] = funcSource(superFuncBound); | |
} | |
// Implement a vague facsimilie of jQuery's data method | |
function elementData(el, name, value) { | |
if (arguments.length == 2) { | |
return el["htmlwidget_data_" + name]; | |
} else if (arguments.length == 3) { | |
el["htmlwidget_data_" + name] = value; | |
return el; | |
} else { | |
throw new Error("Wrong number of arguments for elementData: " + | |
arguments.length); | |
} | |
} | |
// http://stackoverflow.com/questions/3446170/escape-string-for-use-in-javascript-regex | |
function escapeRegExp(str) { | |
return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"); | |
} | |
function hasClass(el, className) { | |
var re = new RegExp("\\b" + escapeRegExp(className) + "\\b"); | |
return re.test(el.className); | |
} | |
// elements - array (or array-like object) of HTML elements | |
// className - class name to test for | |
// include - if true, only return elements with given className; | |
// if false, only return elements *without* given className | |
function filterByClass(elements, className, include) { | |
var results = []; | |
for (var i = 0; i < elements.length; i++) { | |
if (hasClass(elements[i], className) == include) | |
results.push(elements[i]); | |
} | |
return results; | |
} | |
function on(obj, eventName, func) { | |
if (obj.addEventListener) { | |
obj.addEventListener(eventName, func, false); | |
} else if (obj.attachEvent) { | |
obj.attachEvent(eventName, func); | |
} | |
} | |
function off(obj, eventName, func) { | |
if (obj.removeEventListener) | |
obj.removeEventListener(eventName, func, false); | |
else if (obj.detachEvent) { | |
obj.detachEvent(eventName, func); | |
} | |
} | |
// Translate array of values to top/right/bottom/left, as usual with | |
// the "padding" CSS property | |
// https://developer.mozilla.org/en-US/docs/Web/CSS/padding | |
function unpackPadding(value) { | |
if (typeof(value) === "number") | |
value = [value]; | |
if (value.length === 1) { | |
return {top: value[0], right: value[0], bottom: value[0], left: value[0]}; | |
} | |
if (value.length === 2) { | |
return {top: value[0], right: value[1], bottom: value[0], left: value[1]}; | |
} | |
if (value.length === 3) { | |
return {top: value[0], right: value[1], bottom: value[2], left: value[1]}; | |
} | |
if (value.length === 4) { | |
return {top: value[0], right: value[1], bottom: value[2], left: value[3]}; | |
} | |
} | |
// Convert an unpacked padding object to a CSS value | |
function paddingToCss(paddingObj) { | |
return paddingObj.top + "px " + paddingObj.right + "px " + paddingObj.bottom + "px " + paddingObj.left + "px"; | |
} | |
// Makes a number suitable for CSS | |
function px(x) { | |
if (typeof(x) === "number") | |
return x + "px"; | |
else | |
return x; | |
} | |
// Retrieves runtime widget sizing information for an element. | |
// The return value is either null, or an object with fill, padding, | |
// defaultWidth, defaultHeight fields. | |
function sizingPolicy(el) { | |
var sizingEl = document.querySelector("script[data-for='" + el.id + "'][type='application/htmlwidget-sizing']"); | |
if (!sizingEl) | |
return null; | |
var sp = JSON.parse(sizingEl.textContent || sizingEl.text || "{}"); | |
if (viewerMode) { | |
return sp.viewer; | |
} else { | |
return sp.browser; | |
} | |
} | |
function initSizing(el) { | |
var sizing = sizingPolicy(el); | |
if (!sizing) | |
return; | |
var cel = document.getElementById("htmlwidget_container"); | |
if (!cel) | |
return; | |
if (typeof(sizing.padding) !== "undefined") { | |
document.body.style.margin = "0"; | |
document.body.style.padding = paddingToCss(unpackPadding(sizing.padding)); | |
} | |
if (sizing.fill) { | |
document.body.style.overflow = "hidden"; | |
document.body.style.width = "100%"; | |
document.body.style.height = "100%"; | |
document.documentElement.style.width = "100%"; | |
document.documentElement.style.height = "100%"; | |
if (cel) { | |
cel.style.position = "absolute"; | |
var pad = unpackPadding(sizing.padding); | |
cel.style.top = pad.top + "px"; | |
cel.style.right = pad.right + "px"; | |
cel.style.bottom = pad.bottom + "px"; | |
cel.style.left = pad.left + "px"; | |
el.style.width = "100%"; | |
el.style.height = "100%"; | |
} | |
return { | |
getWidth: function() { return cel.offsetWidth; }, | |
getHeight: function() { return cel.offsetHeight; } | |
}; | |
} else { | |
el.style.width = px(sizing.width); | |
el.style.height = px(sizing.height); | |
return { | |
getWidth: function() { return el.offsetWidth; }, | |
getHeight: function() { return el.offsetHeight; } | |
}; | |
} | |
} | |
// Default implementations for methods | |
var defaults = { | |
find: function(scope) { | |
return querySelectorAll(scope, "." + this.name); | |
}, | |
renderError: function(el, err) { | |
var $el = $(el); | |
this.clearError(el); | |
// Add all these error classes, as Shiny does | |
var errClass = "shiny-output-error"; | |
if (err.type !== null) { | |
// use the classes of the error condition as CSS class names | |
errClass = errClass + " " + $.map(asArray(err.type), function(type) { | |
return errClass + "-" + type; | |
}).join(" "); | |
} | |
errClass = errClass + " htmlwidgets-error"; | |
// Is el inline or block? If inline or inline-block, just display:none it | |
// and add an inline error. | |
var display = $el.css("display"); | |
$el.data("restore-display-mode", display); | |
if (display === "inline" || display === "inline-block") { | |
$el.hide(); | |
if (err.message !== "") { | |
var errorSpan = $("<span>").addClass(errClass); | |
errorSpan.text(err.message); | |
$el.after(errorSpan); | |
} | |
} else if (display === "block") { | |
// If block, add an error just after the el, set visibility:none on the | |
// el, and position the error to be on top of the el. | |
// Mark it with a unique ID and CSS class so we can remove it later. | |
$el.css("visibility", "hidden"); | |
if (err.message !== "") { | |
var errorDiv = $("<div>").addClass(errClass).css("position", "absolute") | |
.css("top", el.offsetTop) | |
.css("left", el.offsetLeft) | |
// setting width can push out the page size, forcing otherwise | |
// unnecessary scrollbars to appear and making it impossible for | |
// the element to shrink; so use max-width instead | |
.css("maxWidth", el.offsetWidth) | |
.css("height", el.offsetHeight); | |
errorDiv.text(err.message); | |
$el.after(errorDiv); | |
// Really dumb way to keep the size/position of the error in sync with | |
// the parent element as the window is resized or whatever. | |
var intId = setInterval(function() { | |
if (!errorDiv[0].parentElement) { | |
clearInterval(intId); | |
return; | |
} | |
errorDiv | |
.css("top", el.offsetTop) | |
.css("left", el.offsetLeft) | |
.css("maxWidth", el.offsetWidth) | |
.css("height", el.offsetHeight); | |
}, 500); | |
} | |
} | |
}, | |
clearError: function(el) { | |
var $el = $(el); | |
var display = $el.data("restore-display-mode"); | |
$el.data("restore-display-mode", null); | |
if (display === "inline" || display === "inline-block") { | |
if (display) | |
$el.css("display", display); | |
$(el.nextSibling).filter(".htmlwidgets-error").remove(); | |
} else if (display === "block"){ | |
$el.css("visibility", "inherit"); | |
$(el.nextSibling).filter(".htmlwidgets-error").remove(); | |
} | |
}, | |
sizing: {} | |
}; | |
// Called by widget bindings to register a new type of widget. The definition | |
// object can contain the following properties: | |
// - name (required) - A string indicating the binding name, which will be | |
// used by default as the CSS classname to look for. | |
// - initialize (optional) - A function(el) that will be called once per | |
// widget element; if a value is returned, it will be passed as the third | |
// value to renderValue. | |
// - renderValue (required) - A function(el, data, initValue) that will be | |
// called with data. Static contexts will cause this to be called once per | |
// element; Shiny apps will cause this to be called multiple times per | |
// element, as the data changes. | |
window.HTMLWidgets.widget = function(definition) { | |
if (!definition.name) { | |
throw new Error("Widget must have a name"); | |
} | |
if (!definition.type) { | |
throw new Error("Widget must have a type"); | |
} | |
// Currently we only support output widgets | |
if (definition.type !== "output") { | |
throw new Error("Unrecognized widget type '" + definition.type + "'"); | |
} | |
// TODO: Verify that .name is a valid CSS classname | |
if (!definition.renderValue) { | |
throw new Error("Widget must have a renderValue function"); | |
} | |
// For static rendering (non-Shiny), use a simple widget registration | |
// scheme. We also use this scheme for Shiny apps/documents that also | |
// contain static widgets. | |
window.HTMLWidgets.widgets = window.HTMLWidgets.widgets || []; | |
// Merge defaults into the definition; don't mutate the original definition. | |
var staticBinding = extend({}, defaults, definition); | |
overrideMethod(staticBinding, "find", function(superfunc) { | |
return function(scope) { | |
var results = superfunc(scope); | |
// Filter out Shiny outputs, we only want the static kind | |
return filterByClass(results, "html-widget-output", false); | |
}; | |
}); | |
window.HTMLWidgets.widgets.push(staticBinding); | |
if (shinyMode) { | |
// Shiny is running. Register the definition as an output binding. | |
// Merge defaults into the definition; don't mutate the original definition. | |
// The base object is a Shiny output binding if we're running in Shiny mode, | |
// or an empty object if we're not. | |
var shinyBinding = extend(new Shiny.OutputBinding(), defaults, definition); | |
// Wrap renderValue to handle initialization, which unfortunately isn't | |
// supported natively by Shiny at the time of this writing. | |
// NB: shinyBinding.initialize may be undefined, as it's optional. | |
// Rename initialize to make sure it isn't called by a future version | |
// of Shiny that does support initialize directly. | |
shinyBinding._htmlwidgets_initialize = shinyBinding.initialize; | |
delete shinyBinding.initialize; | |
overrideMethod(shinyBinding, "find", function(superfunc) { | |
return function(scope) { | |
var results = superfunc(scope); | |
// Only return elements that are Shiny outputs, not static ones | |
var dynamicResults = results.filter(".html-widget-output"); | |
// It's possible that whatever caused Shiny to think there might be | |
// new dynamic outputs, also caused there to be new static outputs. | |
// Since there might be lots of different htmlwidgets bindings, we | |
// schedule execution for later--no need to staticRender multiple | |
// times. | |
if (results.length !== dynamicResults.length) | |
scheduleStaticRender(); | |
return dynamicResults; | |
}; | |
}); | |
overrideMethod(shinyBinding, "renderValue", function(superfunc) { | |
return function(el, data) { | |
// Resolve strings marked as javascript literals to objects | |
for (var i = 0; data.evals && i < data.evals.length; i++) { | |
window.HTMLWidgets.evaluateStringMember(data.x, data.evals[i]); | |
} | |
if (!this.renderOnNullValue) { | |
if (data.x === null) { | |
el.style.visibility = "hidden"; | |
return; | |
} else { | |
el.style.visibility = "inherit"; | |
} | |
} | |
if (!elementData(el, "initialized")) { | |
initSizing(el); | |
elementData(el, "initialized", true); | |
if (this._htmlwidgets_initialize) { | |
var result = this._htmlwidgets_initialize(el, el.offsetWidth, | |
el.offsetHeight); | |
elementData(el, "init_result", result); | |
} | |
} | |
Shiny.renderDependencies(data.deps); | |
superfunc(el, data.x, elementData(el, "init_result")); | |
}; | |
}); | |
overrideMethod(shinyBinding, "resize", function(superfunc) { | |
return function(el, width, height) { | |
// Shiny can call resize before initialize/renderValue have been | |
// called, which doesn't make sense for widgets. | |
if (elementData(el, "initialized")) { | |
superfunc(el, width, height, elementData(el, "init_result")); | |
} | |
}; | |
}); | |
Shiny.outputBindings.register(shinyBinding, shinyBinding.name); | |
} | |
}; | |
var scheduleStaticRenderTimerId = null; | |
function scheduleStaticRender() { | |
if (!scheduleStaticRenderTimerId) { | |
scheduleStaticRenderTimerId = setTimeout(function() { | |
scheduleStaticRenderTimerId = null; | |
staticRender(); | |
}, 1); | |
} | |
} | |
// Render static widgets after the document finishes loading | |
// Statically render all elements that are of this widget's class | |
function staticRender() { | |
var bindings = window.HTMLWidgets.widgets || []; | |
for (var i = 0; i < bindings.length; i++) { | |
var binding = bindings[i]; | |
var matches = binding.find(document.documentElement); | |
for (var j = 0; j < matches.length; j++) { | |
var el = matches[j]; | |
var sizeObj = initSizing(el, binding); | |
if (hasClass(el, "html-widget-static-bound")) | |
continue; | |
el.className = el.className + " html-widget-static-bound"; | |
var initResult; | |
if (binding.initialize) { | |
initResult = binding.initialize(el, | |
sizeObj ? sizeObj.getWidth() : el.offsetWidth, | |
sizeObj ? sizeObj.getHeight() : el.offsetHeight | |
); | |
} | |
if (binding.resize) { | |
var lastSize = {}; | |
on(window, "resize", function(e) { | |
var size = { | |
w: sizeObj ? sizeObj.getWidth() : el.offsetWidth, | |
h: sizeObj ? sizeObj.getHeight() : el.offsetHeight | |
}; | |
if (size.w === 0 && size.h === 0) | |
return; | |
if (size.w === lastSize.w && size.h === lastSize.h) | |
return; | |
lastSize = size; | |
binding.resize(el, size.w, size.h, initResult); | |
}); | |
} | |
var scriptData = document.querySelector("script[data-for='" + el.id + "'][type='application/json']"); | |
if (scriptData) { | |
var data = JSON.parse(scriptData.textContent || scriptData.text); | |
// Resolve strings marked as javascript literals to objects | |
for (var i = 0; data.evals && i < data.evals.length; i++) { | |
window.HTMLWidgets.evaluateStringMember(data.x, data.evals[i]); | |
} | |
binding.renderValue(el, data.x, initResult); | |
} | |
} | |
} | |
} | |
// Wait until after the document has loaded to render the widgets. | |
if (document.addEventListener) { | |
document.addEventListener("DOMContentLoaded", function() { | |
document.removeEventListener("DOMContentLoaded", arguments.callee, false); | |
staticRender(); | |
}, false); | |
} else if (document.attachEvent) { | |
document.attachEvent("onreadystatechange", function() { | |
if (document.readyState === "complete") { | |
document.detachEvent("onreadystatechange", arguments.callee); | |
staticRender(); | |
} | |
}); | |
} | |
window.HTMLWidgets.getAttachmentUrl = function(depname, key) { | |
// If no key, default to the first item | |
if (typeof(key) === "undefined") | |
key = 1; | |
var link = document.getElementById(depname + "-" + key + "-attachment"); | |
if (!link) { | |
throw new Error("Attachment " + depname + "/" + key + " not found in document"); | |
} | |
return link.getAttribute("href"); | |
}; | |
window.HTMLWidgets.dataframeToD3 = function(df) { | |
var names = []; | |
var length; | |
for (var name in df) { | |
if (df.hasOwnProperty(name)) | |
names.push(name); | |
if (typeof(df[name]) !== "object" || typeof(df[name].length) === "undefined") { | |
throw new Error("All fields must be arrays"); | |
} else if (typeof(length) !== "undefined" && length !== df[name].length) { | |
throw new Error("All fields must be arrays of the same length"); | |
} | |
length = df[name].length; | |
} | |
var results = []; | |
var item; | |
for (var row = 0; row < length; row++) { | |
item = {}; | |
for (var col = 0; col < names.length; col++) { | |
item[names[col]] = df[names[col]][row]; | |
} | |
results.push(item); | |
} | |
return results; | |
}; | |
window.HTMLWidgets.transposeArray2D = function(array) { | |
var newArray = array[0].map(function(col, i) { | |
return array.map(function(row) { | |
return row[i] | |
}) | |
}); | |
return newArray; | |
}; | |
// Split value at splitChar, but allow splitChar to be escaped | |
// using escapeChar. Any other characters escaped by escapeChar | |
// will be included as usual (including escapeChar itself). | |
function splitWithEscape(value, splitChar, escapeChar) { | |
var results = []; | |
var escapeMode = false; | |
var currentResult = ""; | |
for (var pos = 0; pos < value.length; pos++) { | |
if (!escapeMode) { | |
if (value[pos] === splitChar) { | |
results.push(currentResult); | |
currentResult = ""; | |
} else if (value[pos] === escapeChar) { | |
escapeMode = true; | |
} else { | |
currentResult += value[pos]; | |
} | |
} else { | |
currentResult += value[pos]; | |
escapeMode = false; | |
} | |
} | |
if (currentResult !== "") { | |
results.push(currentResult); | |
} | |
return results; | |
} | |
// Function authored by Yihui/JJ Allaire | |
window.HTMLWidgets.evaluateStringMember = function(o, member) { | |
var parts = splitWithEscape(member, '.', '\\'); | |
for (var i = 0, l = parts.length; i < l; i++) { | |
var part = parts[i]; | |
// part may be a character or 'numeric' member name | |
if (o !== null && typeof o === "object" && part in o) { | |
if (i == (l - 1)) { // if we are at the end of the line then evalulate | |
if (typeof o[part] === "string") | |
o[part] = eval("(" + o[part] + ")"); | |
} else { // otherwise continue to next embedded object | |
o = o[part]; | |
} | |
} | |
} | |
}; | |
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"/> | |
<script src="htmlwidgets.js"></script> | |
<script src="http://d3js.org/d3.v3.min.js"></script> | |
<script src="d3.chart.min.js"></script> | |
<link href="hierStyles.css" rel="stylesheet" /> | |
<script src="d3.chart.layout.hierarchy.js"></script> | |
<script src="hierNetwork.js"></script> | |
</head> | |
<body style="background-color:white;"> | |
<div id="htmlwidget-2208" style="width:960px;height:500px;" class="hierNetwork"></div> | |
<script type="application/json" data-for="htmlwidget-2208">{ "x": { | |
"root": "{\"name\":\"ggplot\",\"children\":[{\"name\":\"data\",\"children\":[{\"name\":\"x\",\"value\":\" [1] 1 2 3 4 5 6 7 8 9 10\"},{\"name\":\"y\",\"value\":\" [1] 1 2 3 4 5 6 7 8 9 10\"},{\"name\":\"PANEL\",\"value\":\" [1] 1 1 1 1 1 1 1 1 1 1\"},{\"name\":\"group\",\"value\":\" [1] 1 1 1 1 1 1 1 1 1 1\"}]},{\"name\":\"panel\",\"children\":[{\"name\":\"layout\",\"children\":[{\"name\":\"PANEL\",\"value\":\"[1] 1\"},{\"name\":\"ROW\",\"value\":\"[1] 1\"},{\"name\":\"COL\",\"value\":\"[1] 1\"},{\"name\":\"SCALE_X\",\"value\":\"[1] 1\"},{\"name\":\"SCALE_Y\",\"value\":\"[1] 1\"}]},{\"name\":\"ranges\",\"children\":[{\"name\":\"x\",\"children\":[{\"name\":\"range\",\"value\":\"[1] 0.55 10.45\"},{\"name\":\"labels\",\"value\":\"[1] \\\"2.5\\\" \\\"5.0\\\" \\\"7.5\\\" \\\"10.0\\\"\"},{\"name\":\"major\",\"value\":\"[1] 0.1969697 0.4494949 0.7020202 0.9545455\"},{\"name\":\"minor\",\"value\":\"[1] 0.07070707 0.19696970 0.32323232 0.44949495 0.57575758 0.70202020 0.82828283 0.95454545\"},{\"name\":\"major_source\",\"value\":\"[1] 2.5 5.0 7.5 10.0\"},{\"name\":\"minor_source\",\"value\":\"[1] 1.25 2.50 3.75 5.00 6.25 7.50 8.75 10.00\"}]},{\"name\":\"y\",\"children\":[{\"name\":\"range\",\"value\":\"[1] 0.55 10.45\"},{\"name\":\"labels\",\"value\":\"[1] \\\"2.5\\\" \\\"5.0\\\" \\\"7.5\\\" \\\"10.0\\\"\"},{\"name\":\"major\",\"value\":\"[1] 0.1969697 0.4494949 0.7020202 0.9545455\"},{\"name\":\"minor\",\"value\":\"[1] 0.07070707 0.19696970 0.32323232 0.44949495 0.57575758 0.70202020 0.82828283 0.95454545\"},{\"name\":\"major_source\",\"value\":\"[1] 2.5 5.0 7.5 10.0\"},{\"name\":\"minor_source\",\"value\":\"[1] 1.25 2.50 3.75 5.00 6.25 7.50 8.75 10.00\"}]}]},{\"name\":\"shrink\",\"children\":[{\"name\":\"NA\",\"value\":\"[1] TRUE\"}]},{\"name\":\"x_scales\",\"children\":[{\"name\":\"aesthetics\",\"children\":[{\"name\":\"NA\",\"value\":\"[1] \\\"x\\\" \\\"xmin\\\" \\\"xmax\\\" \\\"xend\\\" \\\"xintercept\\\"\"}]},{\"name\":\"call\",\"children\":[{\"name\":\"NA\",\"value\":\"continuous_scale(aesthetics = c(\\\"x\\\", \\\"xmin\\\", \\\"xmax\\\", \\\"xend\\\", <br> \\\"xintercept\\\"), scale_name = \\\"position_c\\\", palette = identity, <br> expand = expand, guide = \\\"none\\\")\"}]},{\"name\":\"guide\",\"children\":[{\"name\":\"NA\",\"value\":\"[1] \\\"none\\\"\"}]},{\"name\":\"legend\",\"children\":[{\"name\":\"NA\",\"value\":\"NULL\"}]},{\"name\":\"limits\",\"children\":[{\"name\":\"NA\",\"value\":\"NULL\"}]},{\"name\":\"na\",\"children\":[{\"name\":\"value\",\"value\":\"[1] NA\"}]},{\"name\":\"name\",\"children\":[{\"name\":\"NA\",\"value\":\"NULL\"}]},{\"name\":\"oob\",\"children\":[{\"name\":\"NA\",\"value\":\"function (x, range = c(0, 1), only.finite = TRUE) <br>{<br> force(range)<br> finite <- if (only.finite) <br> is.finite(x)<br> else TRUE<br> x[finite & x < range[1]] <- NA_real_<br> x[finite & x > range[2]] <- NA_real_<br> x<br>}<br><environment: namespace:scales>\"}]},{\"name\":\"palette\",\"children\":[{\"name\":\"NA\",\"value\":\"function (x) <br>x<br><bytecode: 0x000000000a03dc80><br><environment: namespace:base>\"}]},{\"name\":\"range\",\"children\":[{\"name\":\"NA\",\"value\":\"Reference class object of class \\\"Continuous\\\"<br>Field \\\"range\\\":<br>[1] 1 10\"}]},{\"name\":\"rescaler\",\"children\":[{\"name\":\"NA\",\"value\":\"function (x, to = c(0, 1), from = range(x, na.rm = TRUE)) <br>{<br> if (zero_range(from) || zero_range(to)) <br> return(rep(mean(to), length(x)))<br> (x - from[1])/diff(from) * diff(to) + to[1]<br>}<br><environment: namespace:scales>\"}]},{\"name\":\"scale_name\",\"children\":[{\"name\":\"NA\",\"value\":\"[1] \\\"position_c\\\"\"}]},{\"name\":\"trans\",\"children\":[{\"name\":\"name\",\"value\":\"[1] \\\"identity\\\"\"},{\"name\":\"transform\",\"value\":\"function (x) <br>x<br><bytecode: 0x000000000b04c538><br><environment: namespace:base>\"},{\"name\":\"inverse\",\"value\":\"function (x) <br>x<br><bytecode: 0x000000000b04c538><br><environment: namespace:base>\"},{\"name\":\"breaks\",\"value\":\"function (x) <br>{<br> labeling::extended(min(x), max(x), n, only.loose = FALSE, <br> ...)<br>}<br><environment: 0x00000000172b4908>\"},{\"name\":\"format\",\"value\":\"function (x) <br>{<br> if (!is.null(names(x))) <br> return(names(x))<br> format(x, ..., trim = TRUE, justify = \\\"left\\\")<br>}<br><environment: 0x00000000172b4a58>\"},{\"name\":\"domain\",\"value\":\"[1] -Inf Inf\"}]}]},{\"name\":\"y_scales\",\"children\":[{\"name\":\"aesthetics\",\"children\":[{\"name\":\"NA\",\"value\":\"[1] \\\"y\\\" \\\"ymin\\\" \\\"ymax\\\" \\\"yend\\\" \\\"yintercept\\\" \\\"ymin_final\\\" \\\"ymax_final\\\"\"}]},{\"name\":\"call\",\"children\":[{\"name\":\"NA\",\"value\":\"continuous_scale(aesthetics = c(\\\"y\\\", \\\"ymin\\\", \\\"ymax\\\", \\\"yend\\\", <br> \\\"yintercept\\\", \\\"ymin_final\\\", \\\"ymax_final\\\"), scale_name = \\\"position_c\\\", <br> palette = identity, expand = expand, guide = \\\"none\\\")\"}]},{\"name\":\"guide\",\"children\":[{\"name\":\"NA\",\"value\":\"[1] \\\"none\\\"\"}]},{\"name\":\"legend\",\"children\":[{\"name\":\"NA\",\"value\":\"NULL\"}]},{\"name\":\"limits\",\"children\":[{\"name\":\"NA\",\"value\":\"NULL\"}]},{\"name\":\"na\",\"children\":[{\"name\":\"value\",\"value\":\"[1] NA\"}]},{\"name\":\"name\",\"children\":[{\"name\":\"NA\",\"value\":\"NULL\"}]},{\"name\":\"oob\",\"children\":[{\"name\":\"NA\",\"value\":\"function (x, range = c(0, 1), only.finite = TRUE) <br>{<br> force(range)<br> finite <- if (only.finite) <br> is.finite(x)<br> else TRUE<br> x[finite & x < range[1]] <- NA_real_<br> x[finite & x > range[2]] <- NA_real_<br> x<br>}<br><environment: namespace:scales>\"}]},{\"name\":\"palette\",\"children\":[{\"name\":\"NA\",\"value\":\"function (x) <br>x<br><bytecode: 0x000000000a03dc80><br><environment: namespace:base>\"}]},{\"name\":\"range\",\"children\":[{\"name\":\"NA\",\"value\":\"Reference class object of class \\\"Continuous\\\"<br>Field \\\"range\\\":<br>[1] 1 10\"}]},{\"name\":\"rescaler\",\"children\":[{\"name\":\"NA\",\"value\":\"function (x, to = c(0, 1), from = range(x, na.rm = TRUE)) <br>{<br> if (zero_range(from) || zero_range(to)) <br> return(rep(mean(to), length(x)))<br> (x - from[1])/diff(from) * diff(to) + to[1]<br>}<br><environment: namespace:scales>\"}]},{\"name\":\"scale_name\",\"children\":[{\"name\":\"NA\",\"value\":\"[1] \\\"position_c\\\"\"}]},{\"name\":\"trans\",\"children\":[{\"name\":\"name\",\"value\":\"[1] \\\"identity\\\"\"},{\"name\":\"transform\",\"value\":\"function (x) <br>x<br><bytecode: 0x000000000b04c538><br><environment: namespace:base>\"},{\"name\":\"inverse\",\"value\":\"function (x) <br>x<br><bytecode: 0x000000000b04c538><br><environment: namespace:base>\"},{\"name\":\"breaks\",\"value\":\"function (x) <br>{<br> labeling::extended(min(x), max(x), n, only.loose = FALSE, <br> ...)<br>}<br><environment: 0x00000000174f4ba0>\"},{\"name\":\"format\",\"value\":\"function (x) <br>{<br> if (!is.null(names(x))) <br> return(names(x))<br> format(x, ..., trim = TRUE, justify = \\\"left\\\")<br>}<br><environment: 0x00000000174f4cf0>\"},{\"name\":\"domain\",\"value\":\"[1] -Inf Inf\"}]}]}]},{\"name\":\"plot\",\"children\":[{\"name\":\"coordinates\",\"children\":[{\"name\":\"limits\",\"children\":[{\"name\":\"x\",\"value\":\"NULL\"},{\"name\":\"y\",\"value\":\"NULL\"}]}]},{\"name\":\"data\",\"children\":[{\"name\":\"x\",\"value\":\" [1] 1 2 3 4 5 6 7 8 9 10\"}]},{\"name\":\"facet\",\"children\":[{\"name\":\"shrink\",\"value\":\"[1] TRUE\"}]},{\"name\":\"labels\",\"children\":[{\"name\":\"x\",\"value\":\"[1] \\\"x\\\"\"},{\"name\":\"y\",\"value\":\"[1] \\\"x\\\"\"}]},{\"name\":\"layers\",\"children\":[{\"name\":\"NA\",\"value\":\"geom_line: <br>stat_identity: <br>position_identity: (width = NULL, height = NULL)\"}]},{\"name\":\"mapping\",\"children\":[{\"name\":\"x\",\"value\":\"x\"},{\"name\":\"y\",\"value\":\"x\"}]},{\"name\":\"plot_env\",\"children\":[{\"name\":\"NA\",\"value\":\"<environment: R_GlobalEnv>\"}]},{\"name\":\"scales\",\"children\":[{\"name\":\"NA\",\"value\":\"Reference class object of class \\\"Scales\\\"<br>Field \\\"scales\\\":<br>[[1]]<br>continuous_scale(aesthetics = c(\\\"x\\\", \\\"xmin\\\", \\\"xmax\\\", \\\"xend\\\", <br> \\\"xintercept\\\"), scale_name = \\\"position_c\\\", palette = identity, <br> expand = expand, guide = \\\"none\\\")<br><br>[[2]]<br>continuous_scale(aesthetics = c(\\\"y\\\", \\\"ymin\\\", \\\"ymax\\\", \\\"yend\\\", <br> \\\"yintercept\\\", \\\"ymin_final\\\", \\\"ymax_final\\\"), scale_name = \\\"position_c\\\", <br> palette = identity, expand = expand, guide = \\\"none\\\")<br>\"}]}]}]}", | |
"options": { | |
"type": "tree.cartesian", | |
"value": "size", | |
"zoomable": true, | |
"collapsible": true | |
} | |
},"evals": [ ] }</script> | |
<div id="htmlwidget-8822" style="width:960px;height:500px;" class="hierNetwork"></div> | |
<script type="application/json" data-for="htmlwidget-8822">{ "x": { | |
"root": "{\"name\":\"ggplot\",\"children\":[{\"name\":\"data\",\"children\":[{\"name\":\"x\",\"value\":\" [1] 1 2 3 4 5 6 7 8 9 10\"},{\"name\":\"y\",\"value\":\" [1] 1 2 3 4 5 6 7 8 9 10\"},{\"name\":\"PANEL\",\"value\":\" [1] 1 1 1 1 1 1 1 1 1 1\"},{\"name\":\"group\",\"value\":\" [1] 1 1 1 1 1 1 1 1 1 1\"}]},{\"name\":\"panel\",\"children\":[{\"name\":\"layout\",\"children\":[{\"name\":\"PANEL\",\"value\":\"[1] 1\"},{\"name\":\"ROW\",\"value\":\"[1] 1\"},{\"name\":\"COL\",\"value\":\"[1] 1\"},{\"name\":\"SCALE_X\",\"value\":\"[1] 1\"},{\"name\":\"SCALE_Y\",\"value\":\"[1] 1\"}]},{\"name\":\"ranges\",\"children\":[{\"name\":\"x\",\"children\":[{\"name\":\"range\",\"value\":\"[1] 0.55 10.45\"},{\"name\":\"labels\",\"value\":\"[1] \\\"2.5\\\" \\\"5.0\\\" \\\"7.5\\\" \\\"10.0\\\"\"},{\"name\":\"major\",\"value\":\"[1] 0.1969697 0.4494949 0.7020202 0.9545455\"},{\"name\":\"minor\",\"value\":\"[1] 0.07070707 0.19696970 0.32323232 0.44949495 0.57575758 0.70202020 0.82828283 0.95454545\"},{\"name\":\"major_source\",\"value\":\"[1] 2.5 5.0 7.5 10.0\"},{\"name\":\"minor_source\",\"value\":\"[1] 1.25 2.50 3.75 5.00 6.25 7.50 8.75 10.00\"}]},{\"name\":\"y\",\"children\":[{\"name\":\"range\",\"value\":\"[1] 0.55 10.45\"},{\"name\":\"labels\",\"value\":\"[1] \\\"2.5\\\" \\\"5.0\\\" \\\"7.5\\\" \\\"10.0\\\"\"},{\"name\":\"major\",\"value\":\"[1] 0.1969697 0.4494949 0.7020202 0.9545455\"},{\"name\":\"minor\",\"value\":\"[1] 0.07070707 0.19696970 0.32323232 0.44949495 0.57575758 0.70202020 0.82828283 0.95454545\"},{\"name\":\"major_source\",\"value\":\"[1] 2.5 5.0 7.5 10.0\"},{\"name\":\"minor_source\",\"value\":\"[1] 1.25 2.50 3.75 5.00 6.25 7.50 8.75 10.00\"}]}]},{\"name\":\"shrink\",\"children\":[{\"name\":\"NA\",\"value\":\"[1] TRUE\"}]},{\"name\":\"x_scales\",\"children\":[{\"name\":\"aesthetics\",\"children\":[{\"name\":\"NA\",\"value\":\"[1] \\\"x\\\" \\\"xmin\\\" \\\"xmax\\\" \\\"xend\\\" \\\"xintercept\\\"\"}]},{\"name\":\"call\",\"children\":[{\"name\":\"NA\",\"value\":\"continuous_scale(aesthetics = c(\\\"x\\\", \\\"xmin\\\", \\\"xmax\\\", \\\"xend\\\", <br> \\\"xintercept\\\"), scale_name = \\\"position_c\\\", palette = identity, <br> expand = expand, guide = \\\"none\\\")\"}]},{\"name\":\"guide\",\"children\":[{\"name\":\"NA\",\"value\":\"[1] \\\"none\\\"\"}]},{\"name\":\"legend\",\"children\":[{\"name\":\"NA\",\"value\":\"NULL\"}]},{\"name\":\"limits\",\"children\":[{\"name\":\"NA\",\"value\":\"NULL\"}]},{\"name\":\"na\",\"children\":[{\"name\":\"value\",\"value\":\"[1] NA\"}]},{\"name\":\"name\",\"children\":[{\"name\":\"NA\",\"value\":\"NULL\"}]},{\"name\":\"oob\",\"children\":[{\"name\":\"NA\",\"value\":\"function (x, range = c(0, 1), only.finite = TRUE) <br>{<br> force(range)<br> finite <- if (only.finite) <br> is.finite(x)<br> else TRUE<br> x[finite & x < range[1]] <- NA_real_<br> x[finite & x > range[2]] <- NA_real_<br> x<br>}<br><environment: namespace:scales>\"}]},{\"name\":\"palette\",\"children\":[{\"name\":\"NA\",\"value\":\"function (x) <br>x<br><bytecode: 0x000000000a03dc80><br><environment: namespace:base>\"}]},{\"name\":\"range\",\"children\":[{\"name\":\"NA\",\"value\":\"Reference class object of class \\\"Continuous\\\"<br>Field \\\"range\\\":<br>[1] 1 10\"}]},{\"name\":\"rescaler\",\"children\":[{\"name\":\"NA\",\"value\":\"function (x, to = c(0, 1), from = range(x, na.rm = TRUE)) <br>{<br> if (zero_range(from) || zero_range(to)) <br> return(rep(mean(to), length(x)))<br> (x - from[1])/diff(from) * diff(to) + to[1]<br>}<br><environment: namespace:scales>\"}]},{\"name\":\"scale_name\",\"children\":[{\"name\":\"NA\",\"value\":\"[1] \\\"position_c\\\"\"}]},{\"name\":\"trans\",\"children\":[{\"name\":\"name\",\"value\":\"[1] \\\"identity\\\"\"},{\"name\":\"transform\",\"value\":\"function (x) <br>x<br><bytecode: 0x000000000b04c538><br><environment: namespace:base>\"},{\"name\":\"inverse\",\"value\":\"function (x) <br>x<br><bytecode: 0x000000000b04c538><br><environment: namespace:base>\"},{\"name\":\"breaks\",\"value\":\"function (x) <br>{<br> labeling::extended(min(x), max(x), n, only.loose = FALSE, <br> ...)<br>}<br><environment: 0x00000000172b4908>\"},{\"name\":\"format\",\"value\":\"function (x) <br>{<br> if (!is.null(names(x))) <br> return(names(x))<br> format(x, ..., trim = TRUE, justify = \\\"left\\\")<br>}<br><environment: 0x00000000172b4a58>\"},{\"name\":\"domain\",\"value\":\"[1] -Inf Inf\"}]}]},{\"name\":\"y_scales\",\"children\":[{\"name\":\"aesthetics\",\"children\":[{\"name\":\"NA\",\"value\":\"[1] \\\"y\\\" \\\"ymin\\\" \\\"ymax\\\" \\\"yend\\\" \\\"yintercept\\\" \\\"ymin_final\\\" \\\"ymax_final\\\"\"}]},{\"name\":\"call\",\"children\":[{\"name\":\"NA\",\"value\":\"continuous_scale(aesthetics = c(\\\"y\\\", \\\"ymin\\\", \\\"ymax\\\", \\\"yend\\\", <br> \\\"yintercept\\\", \\\"ymin_final\\\", \\\"ymax_final\\\"), scale_name = \\\"position_c\\\", <br> palette = identity, expand = expand, guide = \\\"none\\\")\"}]},{\"name\":\"guide\",\"children\":[{\"name\":\"NA\",\"value\":\"[1] \\\"none\\\"\"}]},{\"name\":\"legend\",\"children\":[{\"name\":\"NA\",\"value\":\"NULL\"}]},{\"name\":\"limits\",\"children\":[{\"name\":\"NA\",\"value\":\"NULL\"}]},{\"name\":\"na\",\"children\":[{\"name\":\"value\",\"value\":\"[1] NA\"}]},{\"name\":\"name\",\"children\":[{\"name\":\"NA\",\"value\":\"NULL\"}]},{\"name\":\"oob\",\"children\":[{\"name\":\"NA\",\"value\":\"function (x, range = c(0, 1), only.finite = TRUE) <br>{<br> force(range)<br> finite <- if (only.finite) <br> is.finite(x)<br> else TRUE<br> x[finite & x < range[1]] <- NA_real_<br> x[finite & x > range[2]] <- NA_real_<br> x<br>}<br><environment: namespace:scales>\"}]},{\"name\":\"palette\",\"children\":[{\"name\":\"NA\",\"value\":\"function (x) <br>x<br><bytecode: 0x000000000a03dc80><br><environment: namespace:base>\"}]},{\"name\":\"range\",\"children\":[{\"name\":\"NA\",\"value\":\"Reference class object of class \\\"Continuous\\\"<br>Field \\\"range\\\":<br>[1] 1 10\"}]},{\"name\":\"rescaler\",\"children\":[{\"name\":\"NA\",\"value\":\"function (x, to = c(0, 1), from = range(x, na.rm = TRUE)) <br>{<br> if (zero_range(from) || zero_range(to)) <br> return(rep(mean(to), length(x)))<br> (x - from[1])/diff(from) * diff(to) + to[1]<br>}<br><environment: namespace:scales>\"}]},{\"name\":\"scale_name\",\"children\":[{\"name\":\"NA\",\"value\":\"[1] \\\"position_c\\\"\"}]},{\"name\":\"trans\",\"children\":[{\"name\":\"name\",\"value\":\"[1] \\\"identity\\\"\"},{\"name\":\"transform\",\"value\":\"function (x) <br>x<br><bytecode: 0x000000000b04c538><br><environment: namespace:base>\"},{\"name\":\"inverse\",\"value\":\"function (x) <br>x<br><bytecode: 0x000000000b04c538><br><environment: namespace:base>\"},{\"name\":\"breaks\",\"value\":\"function (x) <br>{<br> labeling::extended(min(x), max(x), n, only.loose = FALSE, <br> ...)<br>}<br><environment: 0x00000000174f4ba0>\"},{\"name\":\"format\",\"value\":\"function (x) <br>{<br> if (!is.null(names(x))) <br> return(names(x))<br> format(x, ..., trim = TRUE, justify = \\\"left\\\")<br>}<br><environment: 0x00000000174f4cf0>\"},{\"name\":\"domain\",\"value\":\"[1] -Inf Inf\"}]}]}]},{\"name\":\"plot\",\"children\":[{\"name\":\"coordinates\",\"children\":[{\"name\":\"limits\",\"children\":[{\"name\":\"x\",\"value\":\"NULL\"},{\"name\":\"y\",\"value\":\"NULL\"}]}]},{\"name\":\"data\",\"children\":[{\"name\":\"x\",\"value\":\" [1] 1 2 3 4 5 6 7 8 9 10\"}]},{\"name\":\"facet\",\"children\":[{\"name\":\"shrink\",\"value\":\"[1] TRUE\"}]},{\"name\":\"labels\",\"children\":[{\"name\":\"x\",\"value\":\"[1] \\\"x\\\"\"},{\"name\":\"y\",\"value\":\"[1] \\\"x\\\"\"}]},{\"name\":\"layers\",\"children\":[{\"name\":\"NA\",\"value\":\"geom_line: <br>stat_identity: <br>position_identity: (width = NULL, height = NULL)\"}]},{\"name\":\"mapping\",\"children\":[{\"name\":\"x\",\"value\":\"x\"},{\"name\":\"y\",\"value\":\"x\"}]},{\"name\":\"plot_env\",\"children\":[{\"name\":\"NA\",\"value\":\"<environment: R_GlobalEnv>\"}]},{\"name\":\"scales\",\"children\":[{\"name\":\"NA\",\"value\":\"Reference class object of class \\\"Scales\\\"<br>Field \\\"scales\\\":<br>[[1]]<br>continuous_scale(aesthetics = c(\\\"x\\\", \\\"xmin\\\", \\\"xmax\\\", \\\"xend\\\", <br> \\\"xintercept\\\"), scale_name = \\\"position_c\\\", palette = identity, <br> expand = expand, guide = \\\"none\\\")<br><br>[[2]]<br>continuous_scale(aesthetics = c(\\\"y\\\", \\\"ymin\\\", \\\"ymax\\\", \\\"yend\\\", <br> \\\"yintercept\\\", \\\"ymin_final\\\", \\\"ymax_final\\\"), scale_name = \\\"position_c\\\", <br> palette = identity, expand = expand, guide = \\\"none\\\")<br>\"}]}]}]}", | |
"options": { | |
"type": "tree.radial", | |
"value": "size", | |
"zoomable": true, | |
"collapsible": true | |
} | |
},"evals": [ ] }</script> | |
<div id="htmlwidget-9122" style="width:960px;height:500px;" class="hierNetwork"></div> | |
<script type="application/json" data-for="htmlwidget-9122">{ "x": { | |
"root": "{\"name\":\"ggplot\",\"children\":[{\"name\":\"data\",\"children\":[{\"name\":\"x\",\"value\":\" [1] 1 2 3 4 5 6 7 8 9 10\"},{\"name\":\"y\",\"value\":\" [1] 1 2 3 4 5 6 7 8 9 10\"},{\"name\":\"PANEL\",\"value\":\" [1] 1 1 1 1 1 1 1 1 1 1\"},{\"name\":\"group\",\"value\":\" [1] 1 1 1 1 1 1 1 1 1 1\"}]},{\"name\":\"panel\",\"children\":[{\"name\":\"layout\",\"children\":[{\"name\":\"PANEL\",\"value\":\"[1] 1\"},{\"name\":\"ROW\",\"value\":\"[1] 1\"},{\"name\":\"COL\",\"value\":\"[1] 1\"},{\"name\":\"SCALE_X\",\"value\":\"[1] 1\"},{\"name\":\"SCALE_Y\",\"value\":\"[1] 1\"}]},{\"name\":\"ranges\",\"children\":[{\"name\":\"x\",\"children\":[{\"name\":\"range\",\"value\":\"[1] 0.55 10.45\"},{\"name\":\"labels\",\"value\":\"[1] \\\"2.5\\\" \\\"5.0\\\" \\\"7.5\\\" \\\"10.0\\\"\"},{\"name\":\"major\",\"value\":\"[1] 0.1969697 0.4494949 0.7020202 0.9545455\"},{\"name\":\"minor\",\"value\":\"[1] 0.07070707 0.19696970 0.32323232 0.44949495 0.57575758 0.70202020 0.82828283 0.95454545\"},{\"name\":\"major_source\",\"value\":\"[1] 2.5 5.0 7.5 10.0\"},{\"name\":\"minor_source\",\"value\":\"[1] 1.25 2.50 3.75 5.00 6.25 7.50 8.75 10.00\"}]},{\"name\":\"y\",\"children\":[{\"name\":\"range\",\"value\":\"[1] 0.55 10.45\"},{\"name\":\"labels\",\"value\":\"[1] \\\"2.5\\\" \\\"5.0\\\" \\\"7.5\\\" \\\"10.0\\\"\"},{\"name\":\"major\",\"value\":\"[1] 0.1969697 0.4494949 0.7020202 0.9545455\"},{\"name\":\"minor\",\"value\":\"[1] 0.07070707 0.19696970 0.32323232 0.44949495 0.57575758 0.70202020 0.82828283 0.95454545\"},{\"name\":\"major_source\",\"value\":\"[1] 2.5 5.0 7.5 10.0\"},{\"name\":\"minor_source\",\"value\":\"[1] 1.25 2.50 3.75 5.00 6.25 7.50 8.75 10.00\"}]}]},{\"name\":\"shrink\",\"children\":[{\"name\":\"NA\",\"value\":\"[1] TRUE\"}]},{\"name\":\"x_scales\",\"children\":[{\"name\":\"aesthetics\",\"children\":[{\"name\":\"NA\",\"value\":\"[1] \\\"x\\\" \\\"xmin\\\" \\\"xmax\\\" \\\"xend\\\" \\\"xintercept\\\"\"}]},{\"name\":\"call\",\"children\":[{\"name\":\"NA\",\"value\":\"continuous_scale(aesthetics = c(\\\"x\\\", \\\"xmin\\\", \\\"xmax\\\", \\\"xend\\\", <br> \\\"xintercept\\\"), scale_name = \\\"position_c\\\", palette = identity, <br> expand = expand, guide = \\\"none\\\")\"}]},{\"name\":\"guide\",\"children\":[{\"name\":\"NA\",\"value\":\"[1] \\\"none\\\"\"}]},{\"name\":\"legend\",\"children\":[{\"name\":\"NA\",\"value\":\"NULL\"}]},{\"name\":\"limits\",\"children\":[{\"name\":\"NA\",\"value\":\"NULL\"}]},{\"name\":\"na\",\"children\":[{\"name\":\"value\",\"value\":\"[1] NA\"}]},{\"name\":\"name\",\"children\":[{\"name\":\"NA\",\"value\":\"NULL\"}]},{\"name\":\"oob\",\"children\":[{\"name\":\"NA\",\"value\":\"function (x, range = c(0, 1), only.finite = TRUE) <br>{<br> force(range)<br> finite <- if (only.finite) <br> is.finite(x)<br> else TRUE<br> x[finite & x < range[1]] <- NA_real_<br> x[finite & x > range[2]] <- NA_real_<br> x<br>}<br><environment: namespace:scales>\"}]},{\"name\":\"palette\",\"children\":[{\"name\":\"NA\",\"value\":\"function (x) <br>x<br><bytecode: 0x000000000a03dc80><br><environment: namespace:base>\"}]},{\"name\":\"range\",\"children\":[{\"name\":\"NA\",\"value\":\"Reference class object of class \\\"Continuous\\\"<br>Field \\\"range\\\":<br>[1] 1 10\"}]},{\"name\":\"rescaler\",\"children\":[{\"name\":\"NA\",\"value\":\"function (x, to = c(0, 1), from = range(x, na.rm = TRUE)) <br>{<br> if (zero_range(from) || zero_range(to)) <br> return(rep(mean(to), length(x)))<br> (x - from[1])/diff(from) * diff(to) + to[1]<br>}<br><environment: namespace:scales>\"}]},{\"name\":\"scale_name\",\"children\":[{\"name\":\"NA\",\"value\":\"[1] \\\"position_c\\\"\"}]},{\"name\":\"trans\",\"children\":[{\"name\":\"name\",\"value\":\"[1] \\\"identity\\\"\"},{\"name\":\"transform\",\"value\":\"function (x) <br>x<br><bytecode: 0x000000000b04c538><br><environment: namespace:base>\"},{\"name\":\"inverse\",\"value\":\"function (x) <br>x<br><bytecode: 0x000000000b04c538><br><environment: namespace:base>\"},{\"name\":\"breaks\",\"value\":\"function (x) <br>{<br> labeling::extended(min(x), max(x), n, only.loose = FALSE, <br> ...)<br>}<br><environment: 0x00000000172b4908>\"},{\"name\":\"format\",\"value\":\"function (x) <br>{<br> if (!is.null(names(x))) <br> return(names(x))<br> format(x, ..., trim = TRUE, justify = \\\"left\\\")<br>}<br><environment: 0x00000000172b4a58>\"},{\"name\":\"domain\",\"value\":\"[1] -Inf Inf\"}]}]},{\"name\":\"y_scales\",\"children\":[{\"name\":\"aesthetics\",\"children\":[{\"name\":\"NA\",\"value\":\"[1] \\\"y\\\" \\\"ymin\\\" \\\"ymax\\\" \\\"yend\\\" \\\"yintercept\\\" \\\"ymin_final\\\" \\\"ymax_final\\\"\"}]},{\"name\":\"call\",\"children\":[{\"name\":\"NA\",\"value\":\"continuous_scale(aesthetics = c(\\\"y\\\", \\\"ymin\\\", \\\"ymax\\\", \\\"yend\\\", <br> \\\"yintercept\\\", \\\"ymin_final\\\", \\\"ymax_final\\\"), scale_name = \\\"position_c\\\", <br> palette = identity, expand = expand, guide = \\\"none\\\")\"}]},{\"name\":\"guide\",\"children\":[{\"name\":\"NA\",\"value\":\"[1] \\\"none\\\"\"}]},{\"name\":\"legend\",\"children\":[{\"name\":\"NA\",\"value\":\"NULL\"}]},{\"name\":\"limits\",\"children\":[{\"name\":\"NA\",\"value\":\"NULL\"}]},{\"name\":\"na\",\"children\":[{\"name\":\"value\",\"value\":\"[1] NA\"}]},{\"name\":\"name\",\"children\":[{\"name\":\"NA\",\"value\":\"NULL\"}]},{\"name\":\"oob\",\"children\":[{\"name\":\"NA\",\"value\":\"function (x, range = c(0, 1), only.finite = TRUE) <br>{<br> force(range)<br> finite <- if (only.finite) <br> is.finite(x)<br> else TRUE<br> x[finite & x < range[1]] <- NA_real_<br> x[finite & x > range[2]] <- NA_real_<br> x<br>}<br><environment: namespace:scales>\"}]},{\"name\":\"palette\",\"children\":[{\"name\":\"NA\",\"value\":\"function (x) <br>x<br><bytecode: 0x000000000a03dc80><br><environment: namespace:base>\"}]},{\"name\":\"range\",\"children\":[{\"name\":\"NA\",\"value\":\"Reference class object of class \\\"Continuous\\\"<br>Field \\\"range\\\":<br>[1] 1 10\"}]},{\"name\":\"rescaler\",\"children\":[{\"name\":\"NA\",\"value\":\"function (x, to = c(0, 1), from = range(x, na.rm = TRUE)) <br>{<br> if (zero_range(from) || zero_range(to)) <br> return(rep(mean(to), length(x)))<br> (x - from[1])/diff(from) * diff(to) + to[1]<br>}<br><environment: namespace:scales>\"}]},{\"name\":\"scale_name\",\"children\":[{\"name\":\"NA\",\"value\":\"[1] \\\"position_c\\\"\"}]},{\"name\":\"trans\",\"children\":[{\"name\":\"name\",\"value\":\"[1] \\\"identity\\\"\"},{\"name\":\"transform\",\"value\":\"function (x) <br>x<br><bytecode: 0x000000000b04c538><br><environment: namespace:base>\"},{\"name\":\"inverse\",\"value\":\"function (x) <br>x<br><bytecode: 0x000000000b04c538><br><environment: namespace:base>\"},{\"name\":\"breaks\",\"value\":\"function (x) <br>{<br> labeling::extended(min(x), max(x), n, only.loose = FALSE, <br> ...)<br>}<br><environment: 0x00000000174f4ba0>\"},{\"name\":\"format\",\"value\":\"function (x) <br>{<br> if (!is.null(names(x))) <br> return(names(x))<br> format(x, ..., trim = TRUE, justify = \\\"left\\\")<br>}<br><environment: 0x00000000174f4cf0>\"},{\"name\":\"domain\",\"value\":\"[1] -Inf Inf\"}]}]}]},{\"name\":\"plot\",\"children\":[{\"name\":\"coordinates\",\"children\":[{\"name\":\"limits\",\"children\":[{\"name\":\"x\",\"value\":\"NULL\"},{\"name\":\"y\",\"value\":\"NULL\"}]}]},{\"name\":\"data\",\"children\":[{\"name\":\"x\",\"value\":\" [1] 1 2 3 4 5 6 7 8 9 10\"}]},{\"name\":\"facet\",\"children\":[{\"name\":\"shrink\",\"value\":\"[1] TRUE\"}]},{\"name\":\"labels\",\"children\":[{\"name\":\"x\",\"value\":\"[1] \\\"x\\\"\"},{\"name\":\"y\",\"value\":\"[1] \\\"x\\\"\"}]},{\"name\":\"layers\",\"children\":[{\"name\":\"NA\",\"value\":\"geom_line: <br>stat_identity: <br>position_identity: (width = NULL, height = NULL)\"}]},{\"name\":\"mapping\",\"children\":[{\"name\":\"x\",\"value\":\"x\"},{\"name\":\"y\",\"value\":\"x\"}]},{\"name\":\"plot_env\",\"children\":[{\"name\":\"NA\",\"value\":\"<environment: R_GlobalEnv>\"}]},{\"name\":\"scales\",\"children\":[{\"name\":\"NA\",\"value\":\"Reference class object of class \\\"Scales\\\"<br>Field \\\"scales\\\":<br>[[1]]<br>continuous_scale(aesthetics = c(\\\"x\\\", \\\"xmin\\\", \\\"xmax\\\", \\\"xend\\\", <br> \\\"xintercept\\\"), scale_name = \\\"position_c\\\", palette = identity, <br> expand = expand, guide = \\\"none\\\")<br><br>[[2]]<br>continuous_scale(aesthetics = c(\\\"y\\\", \\\"ymin\\\", \\\"ymax\\\", \\\"yend\\\", <br> \\\"yintercept\\\", \\\"ymin_final\\\", \\\"ymax_final\\\"), scale_name = \\\"position_c\\\", <br> palette = identity, expand = expand, guide = \\\"none\\\")<br>\"}]}]}]}", | |
"options": { | |
"type": "cluster.cartesian", | |
"value": "size", | |
"zoomable": true, | |
"collapsible": true | |
} | |
},"evals": [ ] }</script> | |
<div id="htmlwidget-1788" style="width:960px;height:500px;" class="hierNetwork"></div> | |
<script type="application/json" data-for="htmlwidget-1788">{ "x": { | |
"root": "{\"name\":\"ggplot\",\"children\":[{\"name\":\"data\",\"children\":[{\"name\":\"x\",\"value\":\" [1] 1 2 3 4 5 6 7 8 9 10\"},{\"name\":\"y\",\"value\":\" [1] 1 2 3 4 5 6 7 8 9 10\"},{\"name\":\"PANEL\",\"value\":\" [1] 1 1 1 1 1 1 1 1 1 1\"},{\"name\":\"group\",\"value\":\" [1] 1 1 1 1 1 1 1 1 1 1\"}]},{\"name\":\"panel\",\"children\":[{\"name\":\"layout\",\"children\":[{\"name\":\"PANEL\",\"value\":\"[1] 1\"},{\"name\":\"ROW\",\"value\":\"[1] 1\"},{\"name\":\"COL\",\"value\":\"[1] 1\"},{\"name\":\"SCALE_X\",\"value\":\"[1] 1\"},{\"name\":\"SCALE_Y\",\"value\":\"[1] 1\"}]},{\"name\":\"ranges\",\"children\":[{\"name\":\"x\",\"children\":[{\"name\":\"range\",\"value\":\"[1] 0.55 10.45\"},{\"name\":\"labels\",\"value\":\"[1] \\\"2.5\\\" \\\"5.0\\\" \\\"7.5\\\" \\\"10.0\\\"\"},{\"name\":\"major\",\"value\":\"[1] 0.1969697 0.4494949 0.7020202 0.9545455\"},{\"name\":\"minor\",\"value\":\"[1] 0.07070707 0.19696970 0.32323232 0.44949495 0.57575758 0.70202020 0.82828283 0.95454545\"},{\"name\":\"major_source\",\"value\":\"[1] 2.5 5.0 7.5 10.0\"},{\"name\":\"minor_source\",\"value\":\"[1] 1.25 2.50 3.75 5.00 6.25 7.50 8.75 10.00\"}]},{\"name\":\"y\",\"children\":[{\"name\":\"range\",\"value\":\"[1] 0.55 10.45\"},{\"name\":\"labels\",\"value\":\"[1] \\\"2.5\\\" \\\"5.0\\\" \\\"7.5\\\" \\\"10.0\\\"\"},{\"name\":\"major\",\"value\":\"[1] 0.1969697 0.4494949 0.7020202 0.9545455\"},{\"name\":\"minor\",\"value\":\"[1] 0.07070707 0.19696970 0.32323232 0.44949495 0.57575758 0.70202020 0.82828283 0.95454545\"},{\"name\":\"major_source\",\"value\":\"[1] 2.5 5.0 7.5 10.0\"},{\"name\":\"minor_source\",\"value\":\"[1] 1.25 2.50 3.75 5.00 6.25 7.50 8.75 10.00\"}]}]},{\"name\":\"shrink\",\"children\":[{\"name\":\"NA\",\"value\":\"[1] TRUE\"}]},{\"name\":\"x_scales\",\"children\":[{\"name\":\"aesthetics\",\"children\":[{\"name\":\"NA\",\"value\":\"[1] \\\"x\\\" \\\"xmin\\\" \\\"xmax\\\" \\\"xend\\\" \\\"xintercept\\\"\"}]},{\"name\":\"call\",\"children\":[{\"name\":\"NA\",\"value\":\"continuous_scale(aesthetics = c(\\\"x\\\", \\\"xmin\\\", \\\"xmax\\\", \\\"xend\\\", <br> \\\"xintercept\\\"), scale_name = \\\"position_c\\\", palette = identity, <br> expand = expand, guide = \\\"none\\\")\"}]},{\"name\":\"guide\",\"children\":[{\"name\":\"NA\",\"value\":\"[1] \\\"none\\\"\"}]},{\"name\":\"legend\",\"children\":[{\"name\":\"NA\",\"value\":\"NULL\"}]},{\"name\":\"limits\",\"children\":[{\"name\":\"NA\",\"value\":\"NULL\"}]},{\"name\":\"na\",\"children\":[{\"name\":\"value\",\"value\":\"[1] NA\"}]},{\"name\":\"name\",\"children\":[{\"name\":\"NA\",\"value\":\"NULL\"}]},{\"name\":\"oob\",\"children\":[{\"name\":\"NA\",\"value\":\"function (x, range = c(0, 1), only.finite = TRUE) <br>{<br> force(range)<br> finite <- if (only.finite) <br> is.finite(x)<br> else TRUE<br> x[finite & x < range[1]] <- NA_real_<br> x[finite & x > range[2]] <- NA_real_<br> x<br>}<br><environment: namespace:scales>\"}]},{\"name\":\"palette\",\"children\":[{\"name\":\"NA\",\"value\":\"function (x) <br>x<br><bytecode: 0x000000000a03dc80><br><environment: namespace:base>\"}]},{\"name\":\"range\",\"children\":[{\"name\":\"NA\",\"value\":\"Reference class object of class \\\"Continuous\\\"<br>Field \\\"range\\\":<br>[1] 1 10\"}]},{\"name\":\"rescaler\",\"children\":[{\"name\":\"NA\",\"value\":\"function (x, to = c(0, 1), from = range(x, na.rm = TRUE)) <br>{<br> if (zero_range(from) || zero_range(to)) <br> return(rep(mean(to), length(x)))<br> (x - from[1])/diff(from) * diff(to) + to[1]<br>}<br><environment: namespace:scales>\"}]},{\"name\":\"scale_name\",\"children\":[{\"name\":\"NA\",\"value\":\"[1] \\\"position_c\\\"\"}]},{\"name\":\"trans\",\"children\":[{\"name\":\"name\",\"value\":\"[1] \\\"identity\\\"\"},{\"name\":\"transform\",\"value\":\"function (x) <br>x<br><bytecode: 0x000000000b04c538><br><environment: namespace:base>\"},{\"name\":\"inverse\",\"value\":\"function (x) <br>x<br><bytecode: 0x000000000b04c538><br><environment: namespace:base>\"},{\"name\":\"breaks\",\"value\":\"function (x) <br>{<br> labeling::extended(min(x), max(x), n, only.loose = FALSE, <br> ...)<br>}<br><environment: 0x00000000172b4908>\"},{\"name\":\"format\",\"value\":\"function (x) <br>{<br> if (!is.null(names(x))) <br> return(names(x))<br> format(x, ..., trim = TRUE, justify = \\\"left\\\")<br>}<br><environment: 0x00000000172b4a58>\"},{\"name\":\"domain\",\"value\":\"[1] -Inf Inf\"}]}]},{\"name\":\"y_scales\",\"children\":[{\"name\":\"aesthetics\",\"children\":[{\"name\":\"NA\",\"value\":\"[1] \\\"y\\\" \\\"ymin\\\" \\\"ymax\\\" \\\"yend\\\" \\\"yintercept\\\" \\\"ymin_final\\\" \\\"ymax_final\\\"\"}]},{\"name\":\"call\",\"children\":[{\"name\":\"NA\",\"value\":\"continuous_scale(aesthetics = c(\\\"y\\\", \\\"ymin\\\", \\\"ymax\\\", \\\"yend\\\", <br> \\\"yintercept\\\", \\\"ymin_final\\\", \\\"ymax_final\\\"), scale_name = \\\"position_c\\\", <br> palette = identity, expand = expand, guide = \\\"none\\\")\"}]},{\"name\":\"guide\",\"children\":[{\"name\":\"NA\",\"value\":\"[1] \\\"none\\\"\"}]},{\"name\":\"legend\",\"children\":[{\"name\":\"NA\",\"value\":\"NULL\"}]},{\"name\":\"limits\",\"children\":[{\"name\":\"NA\",\"value\":\"NULL\"}]},{\"name\":\"na\",\"children\":[{\"name\":\"value\",\"value\":\"[1] NA\"}]},{\"name\":\"name\",\"children\":[{\"name\":\"NA\",\"value\":\"NULL\"}]},{\"name\":\"oob\",\"children\":[{\"name\":\"NA\",\"value\":\"function (x, range = c(0, 1), only.finite = TRUE) <br>{<br> force(range)<br> finite <- if (only.finite) <br> is.finite(x)<br> else TRUE<br> x[finite & x < range[1]] <- NA_real_<br> x[finite & x > range[2]] <- NA_real_<br> x<br>}<br><environment: namespace:scales>\"}]},{\"name\":\"palette\",\"children\":[{\"name\":\"NA\",\"value\":\"function (x) <br>x<br><bytecode: 0x000000000a03dc80><br><environment: namespace:base>\"}]},{\"name\":\"range\",\"children\":[{\"name\":\"NA\",\"value\":\"Reference class object of class \\\"Continuous\\\"<br>Field \\\"range\\\":<br>[1] 1 10\"}]},{\"name\":\"rescaler\",\"children\":[{\"name\":\"NA\",\"value\":\"function (x, to = c(0, 1), from = range(x, na.rm = TRUE)) <br>{<br> if (zero_range(from) || zero_range(to)) <br> return(rep(mean(to), length(x)))<br> (x - from[1])/diff(from) * diff(to) + to[1]<br>}<br><environment: namespace:scales>\"}]},{\"name\":\"scale_name\",\"children\":[{\"name\":\"NA\",\"value\":\"[1] \\\"position_c\\\"\"}]},{\"name\":\"trans\",\"children\":[{\"name\":\"name\",\"value\":\"[1] \\\"identity\\\"\"},{\"name\":\"transform\",\"value\":\"function (x) <br>x<br><bytecode: 0x000000000b04c538><br><environment: namespace:base>\"},{\"name\":\"inverse\",\"value\":\"function (x) <br>x<br><bytecode: 0x000000000b04c538><br><environment: namespace:base>\"},{\"name\":\"breaks\",\"value\":\"function (x) <br>{<br> labeling::extended(min(x), max(x), n, only.loose = FALSE, <br> ...)<br>}<br><environment: 0x00000000174f4ba0>\"},{\"name\":\"format\",\"value\":\"function (x) <br>{<br> if (!is.null(names(x))) <br> return(names(x))<br> format(x, ..., trim = TRUE, justify = \\\"left\\\")<br>}<br><environment: 0x00000000174f4cf0>\"},{\"name\":\"domain\",\"value\":\"[1] -Inf Inf\"}]}]}]},{\"name\":\"plot\",\"children\":[{\"name\":\"coordinates\",\"children\":[{\"name\":\"limits\",\"children\":[{\"name\":\"x\",\"value\":\"NULL\"},{\"name\":\"y\",\"value\":\"NULL\"}]}]},{\"name\":\"data\",\"children\":[{\"name\":\"x\",\"value\":\" [1] 1 2 3 4 5 6 7 8 9 10\"}]},{\"name\":\"facet\",\"children\":[{\"name\":\"shrink\",\"value\":\"[1] TRUE\"}]},{\"name\":\"labels\",\"children\":[{\"name\":\"x\",\"value\":\"[1] \\\"x\\\"\"},{\"name\":\"y\",\"value\":\"[1] \\\"x\\\"\"}]},{\"name\":\"layers\",\"children\":[{\"name\":\"NA\",\"value\":\"geom_line: <br>stat_identity: <br>position_identity: (width = NULL, height = NULL)\"}]},{\"name\":\"mapping\",\"children\":[{\"name\":\"x\",\"value\":\"x\"},{\"name\":\"y\",\"value\":\"x\"}]},{\"name\":\"plot_env\",\"children\":[{\"name\":\"NA\",\"value\":\"<environment: R_GlobalEnv>\"}]},{\"name\":\"scales\",\"children\":[{\"name\":\"NA\",\"value\":\"Reference class object of class \\\"Scales\\\"<br>Field \\\"scales\\\":<br>[[1]]<br>continuous_scale(aesthetics = c(\\\"x\\\", \\\"xmin\\\", \\\"xmax\\\", \\\"xend\\\", <br> \\\"xintercept\\\"), scale_name = \\\"position_c\\\", palette = identity, <br> expand = expand, guide = \\\"none\\\")<br><br>[[2]]<br>continuous_scale(aesthetics = c(\\\"y\\\", \\\"ymin\\\", \\\"ymax\\\", \\\"yend\\\", <br> \\\"yintercept\\\", \\\"ymin_final\\\", \\\"ymax_final\\\"), scale_name = \\\"position_c\\\", <br> palette = identity, expand = expand, guide = \\\"none\\\")<br>\"}]}]}]}", | |
"options": { | |
"type": "cluster.radial", | |
"value": "size", | |
"zoomable": true, | |
"collapsible": true | |
} | |
},"evals": [ ] }</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment