D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
FrissAnalytics
Full window
Github gist
Radial Dendrogram
forked from
mbostock
's block:
Radial Dendrogram
<!DOCTYPE html> <meta charset="utf-8"> <style> .node circle { fill: #999; } .node text { font: 10px sans-serif; } .node--internal circle { fill: #555; } .node--internal text { text-shadow: 0 1px 0 #fff, 0 -1px 0 #fff, 1px 0 0 #fff, -1px 0 0 #fff; } .link { fill: none; stroke: #555; stroke-opacity: 0.4; stroke-width: 1.5px; } </style> <svg width="960" height="900"></svg> <script src="//d3js.org/d3.v4.min.js"></script> <script> var svg = d3.select("svg"), width = +svg.attr("width"), height = +svg.attr("height"), g = svg.append("g").attr("transform", "translate(" + width / 2 + "," + (height / 2 + 20) + ")"); var stratify = d3.stratify() .parentId(function(d) { return d.id.substring(0, d.id.lastIndexOf(".")); }); var cluster = d3.cluster() .size([360, width / 2 - 120]); var data = [{"name":"master","parent":""},{"name":"Claim","parent":"master"},{"name":"Policy","parent":"master"},{"name":"LegalEntity","parent":"master"},{"name":"Object","parent":"master"},{"name":"Company","parent":"master"},{"name":"accident_type","parent":"Claim"},{"name":"alcohol_drugs","parent":"Claim"},{"name":"cause","parent":"Claim"},{"name":"causer","parent":"Claim"},{"name":"cause_type","parent":"Claim"},{"name":"! claim_amount","parent":"Claim"},{"name":"claim_status","parent":"Claim"},{"name":"claim_type","parent":"Claim"},{"name":"damage_list","parent":"Claim"},{"name":"! date_occurred","parent":"Claim"},{"name":"! date_reported","parent":"Claim"},{"name":"! friss_score","parent":"Claim"},{"name":"liability","parent":"Claim"},{"name":"locality","parent":"Claim"},{"name":"location_type","parent":"Claim"},{"name":"number_of_injured","parent":"Claim"},{"name":"number_of_passengers","parent":"Claim"},{"name":"number_of_third_parties","parent":"Claim"},{"name":"number_of_vehicles_involved","parent":"Claim"},{"name":"policereport_number","parent":"Claim"},{"name":"process","parent":"Claim"},{"name":"product","parent":"Claim"},{"name":"report_type","parent":"Claim"},{"name":"sector","parent":"Claim"},{"name":"time_occurred","parent":"Claim"},{"name":"coverage_list","parent":"Policy"},{"name":"! policyid","parent":"Policy"},{"name":"policy_startdate","parent":"Policy"},{"name":"policy_type","parent":"Policy"},{"name":"address","parent":"LegalEntity"},{"name":"addressline","parent":"LegalEntity"},{"name":"bankaccount","parent":"LegalEntity"},{"name":"bankaccount_iban","parent":"LegalEntity"},{"name":"city","parent":"LegalEntity"},{"name":"country","parent":"LegalEntity"},{"name":"date_of_birth","parent":"LegalEntity"},{"name":"drivers_license","parent":"LegalEntity"},{"name":"email","parent":"LegalEntity"},{"name":"external_reference","parent":"LegalEntity"},{"name":"first_name","parent":"LegalEntity"},{"name":"fraud_registration","parent":"LegalEntity"},{"name":"full_name","parent":"LegalEntity"},{"name":"full_name_address","parent":"LegalEntity"},{"name":"full_name_date_of_birth","parent":"LegalEntity"},{"name":"gender","parent":"LegalEntity"},{"name":"housenumber","parent":"LegalEntity"},{"name":"identification_number","parent":"LegalEntity"},{"name":"identification_type","parent":"LegalEntity"},{"name":"initials","parent":"LegalEntity"},{"name":"last_name","parent":"LegalEntity"},{"name":"! legal_entity_id","parent":"LegalEntity"},{"name":"legal_form","parent":"LegalEntity"},{"name":"mobile_phone","parent":"LegalEntity"},{"name":"passport_number","parent":"LegalEntity"},{"name":"phone","parent":"LegalEntity"},{"name":"reference_number","parent":"LegalEntity"},{"name":"salutation","parent":"LegalEntity"},{"name":"street","parent":"LegalEntity"},{"name":"zip","parent":"LegalEntity"},{"name":"zip_housenumber_date_of_birth","parent":"LegalEntity"},{"name":"bodystyle","parent":"Object"},{"name":"cash_settlement","parent":"Object"},{"name":"fraud_registration","parent":"Object"},{"name":"inspector_category","parent":"Object"},{"name":"license_plate","parent":"Object"},{"name":"make","parent":"Object"},{"name":"make_model","parent":"Object"},{"name":"model","parent":"Object"},{"name":"! object_id","parent":"Object"},{"name":"total_loss","parent":"Object"},{"name":"vehicle_identification_number","parent":"Object"},{"name":"vehicle_number","parent":"Object"},{"name":"! company_name","parent":"Company"},{"name":"company_number","parent":"Company"},{"name":"id","parent":"Company"},{"name":"is_company","parent":"Company"}]; var root = d3.stratify() .id(function(d) { return d.name; }) .parentId(function(d) { return d.parent; }) (data); cluster(root); var link = g.selectAll(".link") .data(root.descendants().slice(1)) .enter().append("path") .attr("class", "link") .attr("d", function(d) { return "M" + project(d.x, d.y) + "C" + project(d.x, (d.y + d.parent.y) / 2) + " " + project(d.parent.x, (d.y + d.parent.y) / 2) + " " + project(d.parent.x, d.parent.y); }); var node = g.selectAll(".node") .data(root.descendants()) .enter().append("g") .attr("class", function(d) { return "node" + (d.children ? " node--internal" : " node--leaf"); }) .attr("transform", function(d) { return "translate(" + project(d.x, d.y) + ")"; }); node.append("circle") .attr("r", 2.5); node.append("text") .attr("dy", "0.31em") .attr("x", function(d) { return d.x < 180 === !d.children ? 6 : -6; }) .style("text-anchor", function(d) { return d.x < 180 === !d.children ? "start" : "end"; }) .attr("transform", function(d) { return "rotate(" + (d.x < 180 ? d.x - 90 : d.x + 90) + ")"; }) .text(function(d) { return d.id.substring(d.id.lastIndexOf(".") + 1); }); function project(x, y) { var angle = (x - 90) / 180 * Math.PI, radius = y; return [radius * Math.cos(angle), radius * Math.sin(angle)]; } </script>
https://d3js.org/d3.v4.min.js