JSFiddle - React, Tailwind, and code Playground
HTML
<h1>Australian Budget 2013-14</h1>
<aside>Click any cell to zoom in, or the top orange label to zoom out.</aside>
<p id="chart"></p>
CSS
body, p, div {
font-family: sans-serif;
}
#chart {
width: 360px;
height: 300px;
background: #ccc;
}
text {
pointer-events: none;
font-family: sans-serif;
font-size: smaller;
}
.grandparent text {
font-weight: bold;
}
rect {
fill: none;
stroke: #fff;
}
rect.parent,
.grandparent rect {
stroke-width: 2px;
}
.grandparent rect {
fill: orange;
}
.grandparent:hover rect {
fill: #ee9700;
}
.children rect.parent,
.grandparent rect {
cursor: pointer;
}
.children rect.parent {
fill: #def;
fill-opacity: 1;
}
.children:hover rect.child {
fill: #bbb;
}
.overlaidText {
font-size: 2.2em;
text-anchor: middle;
fill: white;
fill-opacity: 1;
stroke: black;
stroke-width: 1px;
stroke-opacity: 1;
}
JavaScript
var root = {
"name": "Budget",
"children": [
{
"name": "Social security and welfare",
"children": [
{
"name": "Assistance to the aged",
"children": [
{
"name": "Income support for seniors",
"amount": 39.44
},
{
"name": "Residential and flexible care",
"amount": 8.811
},
{
"name": "Veterans' community care and support",
"amount": 1.695
},
{
"name": "Home support",
"amount": 1.485
},
{
"name": "Home care",
"amount": 1.205
},
{
"name": "National partnership payments - assistance to the aged",
"amount": 0.843
},
{
"name": "Mature age income support",
"amount": 0.439
},
{
"name": "Allowances, concessions and services for for seniors",
"amount": 0.313
}
]
},
{
"name": "Assistance to families with children",
"children": [
{
"name": "Family tax benefit",
"amount": 20.289
},
{
"name": "Parents income support",
"amount": 5.275
},
{
"name": "Child care fee assistance",
"amount": 5.048
}
]
},
{
"name": "Assistance for Indigenous Australians nec",
"amount": 1.043
},
{
"name": "General administration",
"amount": 3.731
}
]
},
{
"name": "Other purposes which could be interesting",
"children": [
{
"name": "Public debt interest",
"amount": 12.456
},
{
"name":...