JSFiddle - React, Tailwind, and code Playground

by gdicerbo

HTML

<script src="http://d3js.org/d3.v3.min.js"></script>
<div id="tree">

    </div>

CSS

body{
            background: #fff;
        }
        .node {
            cursor: pointer;
        }

            .node circle {
                /*fill: #fff;
                stroke: steelblue;*/
                stroke-width: 3px;
            }

            .node text {
                font: 12px sans-serif;
                fill: #000;
            }

        .link {
            fill: none;
            stroke: #ccc;
            stroke-width: 2px;
        }

        .tree {
            margin-bottom: 10px;
            overflow: auto;
        }

JavaScript

$(document).ready(function () {
            //build tree
            function BuildVerticaLTree(treeData, treeContainerDom) {
                var margin = { top: 40, right: 120, bottom: 20, left: 120 };
                var width = 960 - margin.right - margin.left;
                var height = 500 - margin.top - margin.bottom;

                var i = 0, duration = 750;
                var tree = d3.layout.tree()
                    .size([height, width]);
                var diagonal = d3.svg.diagonal()
                    .projection(function (d) { return [d.x, d.y]; });
                var svg = d3.select(treeContainerDom).append("svg")
                    .attr("width", width + margin.right + margin.left)
                    .attr("height", height + margin.top + margin.bottom)
                  .append("g")
                    .attr("transform", "translate(" + margin.left + "," + margin.top + ")");
                root = treeData;

                update(root);
                function update(source) {
                    // Compute the new tree layout.
                    var nodes = tree.nodes(root).reverse(),
                        links = tree.links(nodes);
                    // Normalize for fixed-depth.
                    nodes.forEach(function (d) { d.y = d.depth * 100; });
                    // Declare the nodes…
                    var node = svg.selectAll("g.node")
                        .data(nodes, function (d) { return d.id || (d.id = ++i); });
                    // Enter the nodes.
                    var nodeEnter = node.enter().append("g")
                        .attr("class", "node")
                        .attr("transform", function (d) {
                            return "translate(" + source.x0 + "," + source.y0 + ")";
                        }).on("click", nodeclick);
                    nodeEnter.append("circle")
                     .attr("r", 10)
                        .attr("stroke", function (d) { return d.children ||...