Hi,
Now, I’m trying to make a diagram with d3.js(JavaScript Charts Library)
With below codes, I can see the result correctly on the browser, but I can’t see anything through HTMLViewer(webkit).
Of course, I have tested other example and see the correct one.
Can you try below one and let me know what is wrong?
<!DOCTYPE html>
<meta charset="utf-8">
<style>
text {
font-family: "Helvetica Neue", Helvetica, sans-serif;
}
.name {
font-weight: bold;
}
.about {
fill: #777;
font-size: smaller;
}
.link {
fill: none;
stroke: #000;
shape-rendering: crispEdges;
}
</style>
<body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js"></script>
<script>
var margin = {top: 0, right: 320, bottom: 0, left: 0},
width = 960 - margin.left - margin.right,
height = 500 - margin.top - margin.bottom;
var tree = d3.layout.tree()
.separation(function(a, b) { return a.parent === b.parent ? 1 : .5; })
.children(function(d) { return d.parents; })
.size([height, width]);
var svg = d3.select("body").append("svg")
.attr("width", width + margin.left + margin.right)
.attr("height", height + margin.top + margin.bottom)
.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
d3.json("tree.json", function(error, json) {
if (error) throw error;
var nodes = tree.nodes(json);
alert("Inside json");
var link = svg.selectAll(".link")
.data(tree.links(nodes))
.enter().append("path")
.attr("class", "link")
.attr("d", elbow);
var node = svg.selectAll(".node")
.data(nodes)
.enter().append("g")
.attr("class", "node")
.attr("transform", function(d) { return "translate(" + d.y + "," + d.x + ")"; })
node.append("text")
.attr("class", "HOST")
.attr("x", 8)
.attr("y", -6)
.text(function(d) { return d.HOST; });
node.append("text")
.attr("x", 8)
.attr("y", 8)
.attr("dy", ".71em")
.attr("class", "about lifespan")
.text(function(d) { return d.PORT + "" + d.IP; });
node.append("text")
.attr("x", 8)
.attr("y", 8)
.attr("dy", "1.86em")
.attr("class", "about VERSION")
.text(function(d) { return d.VERSION; });
});
function elbow(d, i) {
return "M" + d.source.y + "," + d.source.x
+ "H" + d.target.y + "V" + d.target.x
+ (d.target.children ? "" : "h" + margin.right);
}
</script>
I used below code in Open event of HTMLViewer.
[code]
Dim Page As FolderItem
Page = GetFolderItem("C:\\work\\index.html", FolderItem.PathTypeAbsolute)
Me.LoadPage Page
[/code]
[code]
tree.json....
{
"H": "s",
"P": "1522",
"IP": "192.168.3.3",
"V": "25",
"parents": [
]
}
[/code]