Skip to content

Instantly share code, notes, and snippets.

@aish-venkat
Forked from mbostock/.block
Last active November 17, 2017 00:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save aish-venkat/f0d85e296cecc5a9ba97288a06b6f797 to your computer and use it in GitHub Desktop.
Save aish-venkat/f0d85e296cecc5a9ba97288a06b6f797 to your computer and use it in GitHub Desktop.
Famine Forecasting Framework

Click on any arc to zoom in. Click on the center circle to zoom out.

A sunburst is similar to a treemap, except it uses a radial layout. The root node of the tree is at the center, with leaves on the circumference. The area (or angle, depending on implementation) of each arc corresponds to its value.

Sunburst design by John Stasko, modified further by Martin Etmajer with design inspiration from Jason Davies.

Designed and maintained by the InForMID research group at Tufts University.

{
"name": "Famine",
"children": [
{"name": "Food Access", "size": 3938,
"children": [
{"name": "Agriculture",
"children": [
{"name": "Storage Capacity",
"children": [
{"name": "Community Storage Access", "size": 300},
{"name": "Community Storage Availability", "size": 300},
{"name": "Produce Storage", "size": 300},
{"name": "Refrigeration Access", "size": 300},
{"name": "Distance to Refrigeration", "size": 300},
{"name": "Refrigeration Availability", "size": 300},
{"name": "Storage & Livestock", "size": 300},
{"name": "Storage Cleanliness", "size": 300},
{"name": "Storage Efficiency", "size": 300},
{"name": "Storage Hygiene", "size": 300},
{"name": "Storage Space Ownership", "size": 300},
{"name": "Storage Space Repair", "size": 300}
]
}
]
},
{"name": "Economics",
"children": [
{"name": "Asset Security",
"children": [
{"name": "Bank Availability", "size": 300},
{"name": "Credit Functionality", "size": 300},
{"name": "Credit Functionality", "size": 300},
{"name": "Insurance Functionality", "size": 300},
{"name": "Knowledge of Banking", "size": 300},
{"name": "Knowledge of Credit", "size": 300},
{"name": "Knowledge of Insurance", "size": 300},
{"name": "Knowledge of Loans", "size": 300},
{"name": "Loan Default Rate", "size": 300},
{"name": "Loan Functionality", "size": 300},
{"name": "Loan Interest Rate", "size": 300}
]
},
{"name": "Market Stability",
"children": [
{"name": "Leading Dairy Price", "size": 300},
{"name": "Leading Dairy Price Fluctuation", "size": 300},
{"name": "Leading Fruit Price", "size": 300},
{"name": "Leading Fruit Price Fluctuation", "size": 300},
{"name": "Leading Meat Price", "size": 300},
{"name": "Leading Meat Price Fluctuation", "size": 300},
{"name": "Leading Staple Food Price", "size": 300},
{"name": "Leading Staple Food Price Fluctuation", "size": 300},
{"name": "Leading Vegetable Price", "size": 300},
{"name": "Leading Vegetable Price Fluctuation", "size": 300},
{"name": "Oil Price", "size": 300},
{"name": "Oil Price Fluctuation", "size": 300},
{"name": "Secondary Staple Food Price", "size": 300},
{"name": "Secondary Staple Food Price Fluctuation", "size": 300}
]
},
{"name": "Markets",
"children": [
{"name": "Assessed cleanliness of Market Storage", "size": 300},
{"name": "Assessed cleanliness of Marketplace", "size": 300},
{"name": "Assessed cleanliness of Transportation", "size": 300},
{"name": "Assessed cleanliness of Water", "size": 300},
{"name": "Assessed Demand", "size": 300},
{"name": "Assessed Likelihood of Sale", "size": 300},
{"name": "Assessed Market Price", "size": 300},
{"name": "Assessed Market Weather", "size": 300}
]
},
{"name": "Purchasing Power",
"children": [
{"name": "Actual Weekly Income", "size": 300},
{"name": "Child Income", "size": 300},
{"name": "Child Purchasing Power", "size": 300},
{"name": "Dollars to Market", "size": 300},
{"name": "Expected Weekly Income", "size": 300},
{"name": "Female Income", "size": 300},
{"name": "Assessed Market Price", "size": 300},
{"name": "Female Purchasing Power", "size": 300},
{"name": "Income from Agriculture", "size": 300},
{"name": "Income from Products", "size": 300},
{"name": "Income from Services", "size": 300},
{"name": "Income on Food", "size": 300},
{"name": "Income on Resources", "size": 300},
{"name": "Income on Services", "size": 300},
{"name": "Income to Market", "size": 300},
{"name": "Net Savings", "size": 300}
]
}
]
},
{"name": "Geography",
"children": [
{"name": "Transportation",
"children": [
{"name": "Cleanliness of Transportation", "size": 300},
{"name": "Dirt Roadways", "size": 300},
{"name": "Duration of Market Stay", "size": 300},
{"name": "Market Access", "size": 300},
{"name": "Market Frequency", "size": 300},
{"name": "Paved Roadways", "size": 300},
{"name": "Travel Animal", "size": 300},
{"name": "Travel Companions", "size": 300},
{"name": "Travel Repairs", "size": 300},
{"name": "Travel Storage", "size": 300},
{"name": "Travel Terrain", "size": 300},
{"name": "Travel Time", "size": 300},
{"name": "Women to Market", "size": 300}
]
}
]
}
]
},
{"name": "Food Availability", "size": 3938,
"children": [
{"name": "Agriculture",
"children": [
{"name": "Agricultural Practices",
"children": [
{"name": "Crop Rotation Frequency", "size": 300},
{"name": "Fertilizer Frequency", "size": 300},
{"name": "Fertilizer Type", "size": 300},
{"name": "Fishing Capacity", "size": 300},
{"name": "Fishing Functionality", "size": 300},
{"name": "Land Restoration", "size": 300},
{"name": "Land Size", "size": 300},
{"name": "Land Utilization", "size": 300},
{"name": "Manure Application Frequency", "size": 300},
{"name": "Seed Availability", "size": 300},
{"name": "Seeding Frequency", "size": 300},
{"name": "Tilling Frequency", "size": 300},
{"name": "Tilling Mechanism", "size": 300}
]
},
{"name": "Livestock",
"children": [
{"name": "Egg Sources", "size": 300},
{"name": "Egg Volume", "size": 300},
{"name": "Meat Source 1 Type", "size": 300},
{"name": "Meat Source 1 Yield", "size": 300},
{"name": "Meat Source 2 Type", "size": 300},
{"name": "Meat Source 2 Yield", "size": 300},
{"name": "Milk Source 1 Type", "size": 300},
{"name": "Milk Source 1 Yield", "size": 300},
{"name": "Milk Source 2 Type", "size": 300},
{"name": "Milk Source 2 Yield", "size": 300}
]
},
{"name": "Production Capacity",
"children": [
{"name": "Fodder Usage", "size": 300},
{"name": "Milling Usage", "size": 300},
{"name": "Preservative Usage", "size": 300},
{"name": "Available Nutritional Diversity", "size": 300},
{"name": "Estimated Waste", "size": 300},
{"name": "Harvest Frequency", "size": 300},
{"name": "Main Crop 1 Type", "size": 300},
{"name": "Main Crop 1 Yield Quantity", "size": 300},
{"name": "Main Crop 2 Type", "size": 300},
{"name": "Main Crop 2 Yield Quantity", "size": 300},
{"name": "Main Crop 3 Type", "size": 300},
{"name": "Main Crop 3 Yield Quantity", "size": 300},
{"name": "Main Crop 4 Type", "size": 300},
{"name": "Self-Consumption", "size": 300}
]
},
{"name": "Soil Biology",
"children": [
{"name": "Manure Type", "size": 300},
{"name": "Soil Carbon Content", "size": 300},
{"name": "Soil Nitrogen Content", "size": 300},
{"name": "Soil Phosphorous Content", "size": 300},
{"name": "Soil Potassium Content", "size": 300},
{"name": "Soil Type", "size": 300},
{"name": "Soil Water Retention", "size": 300}
]
}
]
},
{"name": "Environment",
"children": [
{"name": "Climate",
"children": [
{"name": "Drought Frequency", "size": 300},
{"name": "Drought Functionality", "size": 300},
{"name": "Average Humidity", "size": 300},
{"name": "Average Maximum Temperature", "size": 300},
{"name": "Average Minimum Temperature", "size": 300},
{"name": "Average Rainfall", "size": 300},
{"name": "Average Windspeed", "size": 300},
{"name": "Climatic Disaster Frequency", "size": 300},
{"name": "Natural Disaster Frequency", "size": 300}
]
},
{"name": "Water Availability",
"children": [
{"name": "Subterranean Water Availability", "size": 300},
{"name": "Surface Water Availability", "size": 300}
]
},
{"name": "Water Chemistry",
"children": [
{"name": "Subterranean Water Flow Rate", "size": 300},
{"name": "Subterranean Water Frequency", "size": 300},
{"name": "Subterranean Water Quality", "size": 300},
{"name": "Surface Water Flow Rate", "size": 300},
{"name": "Surface Water Frequency", "size": 300},
{"name": "Surface Water Quality", "size": 300}
]
},
{"name": "Agricultural Practices",
"children": [
{"name": "Irrigated Water Frequency", "size": 300},
{"name": "Irrigated Water Volume", "size": 300},
{"name": "Irrigation Frequency", "size": 300},
{"name": "Rain Dependence", "size": 300}
]
}
]
}
]
},
{"name": "Food Utilization",
"children": [
{"name": "Nutrition",
"children": [
{"name": "Adult Nutrition",
"children": [
{"name": "Food Scarcity", "size": 300},
{"name": "Restricted Diets", "size": 300},
{"name": "Consumption of Undesired Food", "size": 300},
{"name": "Consumption of Smaller Meals", "size": 300},
{"name": "Hunger", "size": 300},
{"name": "Duration of Hunger", "size": 300},
{"name": "Diet Diversity", "size": 300}
]
},
{"name": "Child Nutrition",
"children": [
{"name": "Anorexia Rates", "size": 300},
{"name": "Appetite Loss Rates", "size": 300},
{"name": "Biofortification Intervention", "size": 300},
{"name": "Cognitive Impairment Rate", "size": 300},
{"name": "Deworming Intervention", "size": 300},
{"name": "Micronutrient Intervention", "size": 300},
{"name": "Pellagra / Casal's Necklace", "size": 300},
{"name": "Supplementation Intervention", "size": 300},
{"name": "Wet Beri Beri Rate", "size": 300}
]
},
{"name": "Infant Nutrition",
"children": [
{"name": "Breastfeeding Demand", "size": 300},
{"name": "Breastfeeding Frequency", "size": 300},
{"name": "Complimentary Feeding", "size": 300},
{"name": "Continued Breastfeeding", "size": 300},
{"name": "Exclusive Breastfeeding", "size": 300},
{"name": "Formula Usage", "size": 300},
{"name": "Soft Foods Introduction", "size": 300},
{"name": "Therapeutic Feeding", "size": 300},
{"name": "Water Introduction", "size": 300},
{"name": "Follow Up Appointments", "size": 300},
{"name": "Infant Edema", "size": 300},
{"name": "Infant MUAC", "size": 300},
{"name": "Infant Stunting", "size": 300},
{"name": "Infant Underweight", "size": 300},
{"name": "Infant Wasting", "size": 300}
]
},
{"name": "Nutrient Deficiency",
"children": [
{"name": "Calcium Availability", "size": 300},
{"name": "Calcium Status", "size": 300},
{"name": "Iodine Availability", "size": 300},
{"name": "Iodine Status", "size": 300},
{"name": "Iron Availability", "size": 300},
{"name": "Iron Status", "size": 300},
{"name": "Vitamin A Availability", "size": 300},
{"name": "Vitamin A Status", "size": 300},
{"name": "Vitamin B1 Availability", "size": 300},
{"name": "Vitamin B1 Status", "size": 300},
{"name": "Vitamin B2 Availability", "size": 300},
{"name": "Vitamin B2 Status", "size": 300},
{"name": "Vitamin D Availability", "size": 300},
{"name": "Vitamin D Status", "size": 300},
{"name": "Zinc Availability", "size": 300},
{"name": "Zinc Status", "size": 300}
]
}
]
},
{"name": "Public Health",
"children": [
{"name": "Access to Healthcare",
"children": [
{"name": "Health Facility Capacity", "size": 300},
{"name": "Health Facility Energy", "size": 300},
{"name": "Health Facility Hygiene", "size": 300},
{"name": "Health Facility Proximity", "size": 300},
{"name": "Health Facility Sanitation", "size": 300},
{"name": "Health Facility Staffing", "size": 300},
{"name": "Health Facility Wait Time", "size": 300}
]
},
{"name": "Adult Health",
"children": [
{"name": "Cardiovascular Disease", "size": 300},
{"name": "Diabetes", "size": 300},
{"name": "Obesity", "size": 300},
{"name": "Overweight", "size": 300}
]
},
{"name": "Child Health",
"children": [
{"name": "Bone Fracture Rate", "size": 300},
{"name": "Child Mortality Rate", "size": 300},
{"name": "Diarrhea Rates", "size": 300},
{"name": "Dry Beri Beri Rate", "size": 300},
{"name": "Goiter Rate", "size": 300},
{"name": "HIV/AIDS Rates", "size": 300},
{"name": "Pneumonia Rates", "size": 300},
{"name": "Rickets Rate", "size": 300}
]
},
{"name": "Infant Health",
"children": [
{"name": "Tuberculosis Rates", "size": 300},
{"name": "HIV/AIDS ART", "size": 300},
{"name": "Infant BMI", "size": 300},
{"name": "Infant Mortality Rate", "size": 300}
]
},
{"name": "Post-Natal Health",
"children": [
{"name": "Birth Height", "size": 300},
{"name": "Birth Weight", "size": 300},
{"name": "HIB Vaccine", "size": 300},
{"name": "Maternal Mortality Rate", "size": 300},
{"name": "Measles Vaccination", "size": 300},
{"name": "Post-Birth Diarrhea", "size": 300},
{"name": "Post-Birth Hygiene", "size": 300},
{"name": "Post-Birth Insect Repellant", "size": 300},
{"name": "Post-Birth Malaria", "size": 300},
{"name": "Post-Birth Pneumonia", "size": 300},
{"name": "Post-Birth Breastfeeding", "size": 300},
{"name": "Preclampsia", "size": 300},
{"name": "Vaginal Delivery", "size": 300},
{"name": "Kangaroo Care", "size": 300}
]
},
{"name": "Pre-Natal Health",
"children": [
{"name": "Pregnancy Education", "size": 300},
{"name": "Health Facility Guidance", "size": 300},
{"name": "Health Visits", "size": 300},
{"name": "Pregnancy Folic Acid Supplementation", "size": 300},
{"name": "Pregnancy HIV/AIDS Status", "size": 300},
{"name": "Pregnancy Iron Status", "size": 300},
{"name": "Pregnancy Vitamin A Status", "size": 300},
{"name": "Pregnancy Zinc Status", "size": 300}
]
}
]
}
]
}
]
}
<!DOCTYPE html>
<meta charset="utf-8">
<style>
path {
stroke: #fff;
fill-rule: evenodd;
}
text {
font-family: Arial, sans-serif;
font-size: 12px;
}
</style>
<body>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script>
var width = 960,
height = 700,
radius = Math.min(width, height) / 2;
var x = d3.scale.linear()
.range([0, 2 * Math.PI]);
var y = d3.scale.linear()
.range([0, radius]);
var color = d3.scale.category20c();
var svg = d3.select("body").append("svg")
.attr("width", width)
.attr("height", height)
.append("g")
.attr("transform", "translate(" + width / 2 + "," + (height / 2 + 10) + ")");
var partition = d3.layout.partition()
.value(function(d) { return d.size; });
var arc = d3.svg.arc()
.startAngle(function(d) { return Math.max(0, Math.min(2 * Math.PI, x(d.x))); })
.endAngle(function(d) { return Math.max(0, Math.min(2 * Math.PI, x(d.x + d.dx))); })
.innerRadius(function(d) { return Math.max(0, y(d.y)); })
.outerRadius(function(d) { return Math.max(0, y(d.y + d.dy)); });
d3.json("flare.json", function(error, root) {
var g = svg.selectAll("g")
.data(partition.nodes(root))
.enter().append("g");
var path = g.append("path")
.attr("d", arc)
.style("fill", function(d) { return color((d.children ? d : d.parent).name); })
.on("click", click);
var text = g.append("text")
.attr("transform", function(d) { return "rotate(" + computeTextRotation(d) + ")"; })
.attr("x", function(d) { return y(d.y); })
.attr("dx", "6") // margin
.attr("dy", ".35em") // vertical-align
.text(function(d) { return d.name; });
function click(d) {
// fade out all text elements
text.transition().attr("opacity", 0);
path.transition()
.duration(750)
.attrTween("d", arcTween(d))
.each("end", function(e, i) {
// check if the animated element's data e lies within the visible angle span given in d
if (e.x >= d.x && e.x < (d.x + d.dx)) {
// get a selection of the associated text element
var arcText = d3.select(this.parentNode).select("text");
// fade in the text element and recalculate positions
arcText.transition().duration(750)
.attr("opacity", 1)
.attr("transform", function() { return "rotate(" + computeTextRotation(e) + ")" })
.attr("x", function(d) { return y(d.y); });
}
});
}
});
d3.select(self.frameElement).style("height", height + "px");
// Interpolate the scales!
function arcTween(d) {
var xd = d3.interpolate(x.domain(), [d.x, d.x + d.dx]),
yd = d3.interpolate(y.domain(), [d.y, 1]),
yr = d3.interpolate(y.range(), [d.y ? 20 : 0, radius]);
return function(d, i) {
return i
? function(t) { return arc(d); }
: function(t) { x.domain(xd(t)); y.domain(yd(t)).range(yr(t)); return arc(d); };
};
}
function computeTextRotation(d) {
return (x(d.x + d.dx / 2) - Math.PI / 2) / Math.PI * 180;
}
</script>
license: gpl-3.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment