JSFiddle - React, Tailwind, and code Playground
by lukas vojt
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>VR Finance model | Map | Digrin</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="google-site-verification" content="J0tOPTIcRtqAifQs9EyneSqS1kyRR8tRNu3gBos1bMA" />
<!-- needed for bootstrap tooltips-->
<script src="//cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
<link crossorigin="anonymous" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" rel="stylesheet">
<script crossorigin="anonymous" integrity="sha384-ZvpUoO/+PpLXR1lu4jmpXWu80pZlYUAfxl5NsBMWOEPSjUn/6Z/hRTt8+pR6L4N2" src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<script crossorigin="anonymous" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js"></script>
<script crossorigin="anonymous" integrity="sha384-B4gt1jrGC7Jh4AgTPSdUtOBvfO8shuf57BaghqFfPlYxofvL8/KUEfYiJOMMV+rV" src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
<link rel="stylesheet" type="text/css" href="/static/css/sticky-footer.css">
<link rel="stylesheet" type="text/css" href="/static/css/allauth-main.css">
<link rel="stylesheet" type="text/css" href="//cdn.jsdelivr.net/npm/typeahead.js-bootstrap4-css@1.0.0/typeaheadjs.min.css">
<link rel="stylesheet" type="text/css" href="//stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="shortcut icon" href="/static/img/favicon.ico" />
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/sweetalert/1.1.0/sweetalert.min.css">
<style>
.btn-group-xs > .btn, .btn-xs {
padding: .25rem .4rem;
font-size: .875rem;
line-height: .5;
border-radius: .2rem;
}
</style>
<script...
CSS
#chart {
background: #212121;
position: relative;
left: 0px;
right: 0px;
top: 0px;
bottom: 0px;
min-height: 400px;
min-width: 400px;
font-family: 'Vazir', sans-serif;
}
g text.shadow{
text-shadow: 0.025em 0.04em 0 #555;
}
g {
cursor: grab;
fill: #fff;
fill-opacity: 1;
}
rect:hover{
opacity: 0.8;
}
.tooltip {
position: absolute;
padding: 8px;
background: rgba(0, 0, 0, .87);
color: #fff;
border: 0px;
border-radius: 4px;
pointer-events: none;
}
#chart .tooltip hr {
padding: 0;
margin: 8px 0;
}
JavaScript
let data = {"name": "Stock Map", "children": [{"name": "Healthcare", "children": [{"name": "PFE", "sector": "Healthcare", "current_value": 234.24, "pc": 7.21}, {"name": "WBA", "sector": "Healthcare", "current_value": 160.05, "pc": -3.09}, {"name": "JNJ", "sector": "Healthcare", "current_value": 166.45, "pc": 1.32}, {"name": "ABBV", "sector": "Healthcare", "current_value": 327.09, "pc": 0.76}]}, {"name": "Technology", "children": [{"name": "INTC", "sector": "Technology", "current_value": 188.0, "pc": -2.19}, {"name": "AAPL", "sector": "Technology", "current_value": 265.7, "pc": 8.05}, {"name": "CSCO", "sector": "Technology", "current_value": 310.74, "pc": 0.21}]}, {"name": "Energy", "children": [{"name": "XOM", "sector": "Energy", "current_value": 165.87, "pc": -0.96}, {"name": "RDS.B", "sector": "Energy", "current_value": 217.65, "pc": -1.52}]}, {"name": "Financial Services", "children": [{"name": "WFC", "sector": "Financial Services", "current_value": 340.24, "pc": 8.16}]}, {"name": "Consumer Defensive", "children": [{"name": "BTI", "sector": "Consumer Defensive", "current_value": 229.14, "pc": -1.41}, {"name": "KO", "sector": "Consumer Defensive", "current_value": 108.33, "pc": 2.67}, {"name": "TSN", "sector": "Consumer Defensive", "current_value": 235.65, "pc": 5.37}, {"name": "MO", "sector": "Consumer Defensive", "current_value": 141.54, "pc": -8.48}, {"name": "UL", "sector": "Consumer Defensive", "current_value": 173.26, "pc": 3.32}]}, {"name": "Communication Services", "children": [{"name": "T", "sector": "Communication Services", "current_value": 268.96, "pc": -1.25}, {"name": "VZ", "sector": "Communication Services", "current_value": 175.11, "pc": 0.41}]}, {"name": "Real Estate", "children": [{"name": "SPG", "sector": "Real Estate", "current_value": 342.78, "pc": 0.45}, {"name": "DLR", "sector": "Real Estate", "current_value": 301.83, "pc": 6.66}, {"name": "O", "sector": "Real Estate", "current_value": 274.36, "pc": 7.41}]}, {"name": "Industrials",...