gatesbubbletest
This bubble chart visualizes grant funding data from the Gates Foundation, showing the distribution of grants by organization and amount over time. Each circle represents a grant, positioned along a time axis by start date, with the bubble area scaled to the grant amount and colored by funding tier (low, medium, high). A toolbar with toggleable year buttons (e.g., 2008–2010) filters the visualization, animating the bubble positions and sizes in response. The chart uses an animated, force-directed layout to separate bubbles and prevent overlap, with hover tooltips providing detailed grant information. The visualization is rendered in SVG and built with D3 v4, offering an interactive way to explore grant-making patterns across organizations and time. The animation and interactivity allow users to compare funding distributions by year and category. The design is minimal, with a clean white background and simple typography, focusing attention on the data. The source is a gist by 35degrees, under an MIT license.# Gates Bubble Test ## Description This interactive bubble chart visualizes grant-making data from the Bill & Melinda Gates Foundation, mapping 38 education grants by their funding amount and organizational relationships. The visualization presents each grant as a circle, with the bubble size encoding the grant amount and interactive animation revealing the temporal distribution of grants across a 28-month period. ## Design The visualization uses a classic bubble chart layout with **d3.v4** and an animated pack layout. A distinctive feature is the "gates" motif in the title, suggesting the foundation context. The visualization includes: - **Animated year-by-year transitions** triggered by toolbar buttons - **Bubble size** encoding grant amounts (ranging from $5,000 to over $149,000) - **Tooltips** showing grant titles, organizations, and amounts - **Group colors** distinguish low and medium grant amounts - A **floating tooltip** that follows the mouse over circles ## Data The dataset contains grant records from the Gates Foundation, each with a title, recipient organization, total amount, and start date. Each grant is identified by a unique ID and has a categorical group (low/medium/high). The date fields include start month, day, and year for time-based sorting. ## Design The chart displays circles whose areas encode the grant amounts. Users can select a year from the toolbar to animate the bubbles, transitioning them to new positions based on the grant data. The animation gives a sense of the data's temporal evolution — as grants start in different months, the bubble positions shift to reveal how the funding landscape changes over time. ## Key Features - **Bubble Layout**: Circles sized by grant amount, arranged with a collision-force layout in a fixed region. The chart uses a D3 bubble layout. Circle areas are proportional to the amount of each grant. The visualization filters grants by their start year — 2008, 2009, 2010 — and animates between these selections. The chart includes a toolbar with buttons for filtering by year, and hover tooltips. - **Interaction**: Hovering over each bubble shows a tooltip with grant title, organization, and grant amount. Clicking a bubble links to more information. - **Animation**: When switching years, the bubbles are transitioned between different positions and sizes. - **Tooltip**: On hover, the bubble’s stroke and fill are highlighted, and the tooltip is displayed near the cursor. The tooltip includes the grant title, organization, total amount, and grant start date. - **Axes & Legends**: A year label at the top of the visualization indicates the currently displayed year. The color-coded legend is displayed horizontally below the chart and can be used to filter grants by size. Filtering updates the displayed circles with an animated transition. There is no x or y axis because this is a bubble chart. The chart is a bubble chart built from a CSV of grants data. It uses a force simulation with collision detection to pack circles by category (the "group" column in the data) and show the total grant amounts as the area of each circle. Clicking a button filters the data by grant size ("low", "medium", or "high"), and hovering over a circle shows a tooltip with the grant details. Below the chart, there is a footer with the text "Made with Blockbuilder". The chart includes a title "gatesbubbletest" and is based on data from the file "gates_money.csv". The visualization was probably at http://blockbuilder.org/35degrees/gatesbubbletest. The template starts with: <!DOCTYPE html> <meta charset="utf-8"> <script src="https://d3js.org/d3.v4.min.js"></script> <style> body { margin:0;position:fixed;top:0;right:0;bottom:0;left:0; } .a, a:visited, a:active { color: #444; } .container { max-width: 900px; margin: auto; } .button { min-width: 130px; padding: 4px 5px; cursor: pointer; text-align: center; font-size: 13px; border: 1px solid #e0e0e0; text-decoration: none; } .button.active { background: #000; color: #fff; } #vis { width: 940px; height: 600px; clear: both; margin-bottom: 10px; } #toolbar { margin-top: 10px; } .year { font-size: 21px; fill: #aaa; cursor: default; } .tooltip { position: absolute; top: 100px; left: 100px; -moz-border-radius:5px; border-radius: 5px; border: 2px solid #000; background: #fff; opacity: .9; color: black; padding: 10px; width: 300px; font-size: 12px; z-index: 10; } .tooltip .title { font-size: 13px; } .tooltip .name { font-weight:bold; } .footer { text-align: center; } </style> </head> <body> <div id="vis"> <div class="container" id="toolbar"> <button class="button active" data-sort="default">Default order</button> <button class="button" data-sort="name">Sort by Name</button> <button class="button" data-sort="-amount">Sort by Amount</button> </div> </div> <script> function floatingTooltip(tooltipId, width) { var tt = d3.select('body') .append('div') .attr('class', 'tooltip') .attr('id', tooltipId) .style('pointer-events', 'none'); tt.append('div').attr('class', 'title'); tt.append('div').attr('class', 'name'); tt.append('div').attr('class', 'amount'); function show(obj) { if (obj) { tt.transition().duration(200).style('opacity', 0.9); tt.style('left', (d3.event.pageX + 10) + 'px') .style('top', (d3.event.pageY + 10) + 'px') .style('display', 'block'); var title = tt.select(".title").text(obj.organization); var name = tt.select(".name").text(obj.grant_title); var amount = tt.select(".amount").text('$' + Number(obj.total_amount).toLocaleString()); } else { tt.style("opacity", 0); tt.select(".title").innerHTML = ""; } }; tt.style("display", "none"); return tt; }; function floatingTooltip(tooltipId, width) { var tt = d3.select('body') .append('div') .attr('class', 'tooltip') .attr('id', tooltipId); tt.append('div') .attr('class', 'title'); tt.append('div') .attr('class', 'name'); tt.append('div') .attr('class', 'value'); tt.append('div') .attr('class', 'value'); function asHex (int) { var hexNum = int.toString(16); var padding = 3 - hexNum.length; while (padding>0) { hexNum = "0"+hexNum; padding--; } return hexNum; } function tooltipRender(d) { var color = "rgb((" + Math.floor((d.total_amount)/1000*255) + ",0,0)"; var color2 = "rgb(0,0," + Math.floor((d.total_amount)/1000*255) + ")"; var html = "<div class='title'><span class='name'>" + d.grant_title + "</span>" + ", " + d.organization + "</div><br/>" + "<div><span class='name'>Amount: </span>" + d.total_amount + "</div>" + "<div><span class='name'>Group: </span>" + d.group + "</div>" + "<div><span class='name'>Start date: </span>" + d.start_year + "</div>"; tooltip.show(html); } var tt = {}; function floatingTooltip(svgId, width) { var tt = d3.select('body') .append('div') .attr('class', 'tooltip') .style('opacity', 0.0) .style('position', 'absolute') .style('width', width + 'px') .style('display', 'none'); return { show: function(content, event) { tt .html(content) .style('left', (event.layerX + 20) + 'px') .style('top', (event.layerY - 20) + 'px') .style('opacity', 0.9) .style('display', 'block'); }, hide: function() { tt.style('display', 'none'); }, }; } d3.csv('gates_money.csv', function(error, data) { if (error) throw error; var grants = []; data.forEach(function (d) { d.total_amount = +d.total_amount; d.start_year = +d.start_year; d.group = d.group; grants.push(d); }); console.log('total grants', grants.length); var maxAmount = d3.max(grants.map(function(d){ return d.total_amount; })); var yearTitle = d3.select('#vis').append('div') .attr('class', 'year') .text('All grants'); var minYear = 2008; var maxYear = 2010; var year = 2010; var yearIncrement = 0.15; var years = d3.range(minYear, maxYear + 1, 0.1); var iteration = 0; var fadeInfection = 10; var filterYear = null; var filterGroup = 'low'; var mode = "grouped"; var svg = d3.select('#vis') .append('svg') .attr('width', width) .attr('height', height); var div = d3.select('body').append('div') .attr('class', 'tooltip') .style('opacity', 0); function bubbleLocation(d, g, c) { var x = g[c] * 24; var y = 600; var k = 1; var r = d.r; return { x: x, y: y, k: k, r: r }; } var min = 0.6, max = 1.2; var simulation = d3.forceSimulation() .velocityDecay(0.2) .force("x", d3.forceX().x( function(d){ return center.x; } )) .force("y", d3.forceY().y( function(d){ return center.y; } )) .force("charge", d3.forceAllToY().strength(-30)) .force("collide", d3.forceCollide(4)) .force("center", d3.forceCenter(width / 2, height / 2)) .on("tick", tick); var svg = d3.select("#vis").append("svg") .attr("width", width) .attr("height", height); svg.append("rect") .attr("width", width) .attr("height", height) .style("fill", "white") .style("fill-opacity", 0) .style("stroke", "#aaa") .style("stroke-width", "1px") .on("mousemove", function(d, i) { tooltip.hide(); }); var filter = "all"; d3.csv("gates_money.csv", function(d) { d.total_amount = +d.total_amount; d["grant start date"] = d3.timeParse("%-m/%-d/%Y")(d["Grant start date"]); return d; }, function(error, data) { if (error) throw error; var grantsByGroup = d3.nest() .key(function(d) { return d.group; }) .entries(data); var svg = d3.select("#vis").append("svg") .attr("width", width) .attr("height", height) .on("click", function() { tooltip.hide(); }); var circles = svg.selectAll("circle") .data(data) .enter().append("circle") .attr("r", 1e-6) .attr("fill", function(d) { return color(d.group); }) .attr("fill-opacity", 0.5) .attr("stroke", "#000") .attr("stroke-width", 0.5) .attr("cx", function(d) { return center.x; }) .attr("cy", function(d) { return center.y; }); var simulation = d3.forceSimulation() .force("x", d3.forceX(center.x).strength(0.05)) .force("y", d3.forceY(center.y).strength(0.05)) .force("charge", d3.forceManyBody().strength(-30)) .force("collide", d3.forceCollide().radius(5).iterations(2)) .force("charge", d3.forceManyBody().strength(2)) .force("center", d3.forceCenter(width / 2, height / 2)) .force("x", d3.forceX(0.05).x(width / 2)) .force("y", d3.forceY(0.05).y(height / 2)); var radius = d3.scaleSqrt() .range([5, 45]); var yearTitle = {'2008': "2008", '2009': "2009", '2010': "2010"}; var year1955 = '2008'; function vis(selection) { selection.each(function (data) { // set up initial bubble data var csv = d3.csvParse(data); var grantData = csv.filter(function(d) { return d.group == "low"; }); var maxAmount = d3.max(grantData, function(d) { return +d.total_amount; }); radiusScale = d3.scaleSqrt() .domain([0, maxAmount]) .range([0, 55]); var svg = d3.select("#vis").append("svg") .attr("width", width) .attr("height", height) .append("g"); d3.select("#toolbar").selectAll("a") .data(["low", "medium", "high"]) .enter() .append("a") .attr("class", "button") .attr("id", function(d) { return d; }) .on("click", function() { d3.selectAll(".button") .classed("active", false); d3.select(this).classed("active", true); filterBubbles(this.id); }) .text(function(d) { return d; }); var nodes = []; var allGroups = []; var colorScale = d3.scaleOrdinal() .range(["#568d8c", "#F2B134", "#605F60", "#9A9A9A", "#009C8C"]); var svg = d3.select("#vis").append("svg") .attr("width", width) .attr("height", height); var circles = svg.selectAll(".circle"); var labels = svg.selectAll(".label"); var yearTitle = svg.append("text") .attr("class", "year") .attr("x", width / 2) .attr("y", 30) .attr("text-anchor", "middle") .text("2008"); var simulation; var charge = -1; var gravity = 0.1; var friction = 0.7; d3.csv("gates_money.csv", function(error, data) { data.forEach(function(d) { d.total_amount = +d.total_amount; }); var filtered = data.filter(function (d) { return d.start_year === 2008; }); var years = [2008, 2009, 2010, 2011, 2012, 2013]; var color = d3.scaleOrdinal() .domain(["low", "medium", "high"]) .range(["#FFA066", "#B7D968", "#6EC6D9"]); var minimumYear = 2008; var yearTitle = d3.select('#vis').append('p') .attr('class', 'year'); function render(year) { var data = filteredDataset[year]; yearTitle.text(year).classed('year', true); var allGroups = data.map(function(d){return d.group}); var flatGroups = allGroups.reduce(function(a, b) { return a.concat(b); }, []); var uniqueGroups = d3.set(flatGroups).values(); var maxAmount = d3.max(data, function(d) { return d.total_amount; }); d3.select('#toolbar').html(''); uniqueGroups.forEach(function(group, i) { var tag = d3.select('#toolbar').append('a') .attr('class', 'button') .text(group) .on('click', function() { updateCharts(group); }); if (group === 'low') { tag.classed('active', true); } }); var x = d3.scaleLinear() .range([0, width]) .domain([0, 140]); var y = d3.scaleLinear() .range([0, height]) .domain([0, 140]); var color = d3.scaleOrdinal() .range(["#98abc5", "#8a89a6", "#7b6883", "#6b486b", "#a05d56", "#d0743c", "#ff8c00"]); var xArr = []; var yArr = []; var rArr = []; var csv = d3.csvParse(d3.select("pre#csv").text()); var data = csv.filter(function(d){ return d.group === 'low' || d.group === 'medium' || d.group === 'high'; }) // sort them data.sort(function(a,b){ return b.total_amount - a.total_amount;}); // set the depth of the circles data.forEach(function(d) { d.group = d.group; }); var svg = d3.select('#vis').append('svg') .attr('width', width) .attr('height', height); // returns 1 if positive, -1 if negative, 0 if 0 function getSign(r) { return r > 0 ? 1 : (r < 0 ? -1 : 0); } // returns -1 always function neg(r) { return -1; } // returns +1 always function pos(r) { return 1; } // returns 0 function zero(r) { return 0; } // Compute the colliding node. function nodeCollision(node, b, x, y) { var r = node.r + b.r, nx1 = node.x - b.r, nx2 = node.x + b.r, ny1 = node.y - b.r, ny2 = node.y + b.r; return nx1 < x && x < nx2 && ny1 < y && y < ny2 ? node : null; } function labelCollision(node) { var pos = node.pos; var size = node.r + 20; return d3.quadtree() .x(function(d) { return d.x; }) .y(function(d) { return d.y; }) .addAll(node) .find(pos[0], pos[1], size); } function floatingTooltip(id, width) { var tt = d3.select('body') .append('div') .attr('class', 'tooltip') .attr('id', id); tt.append('div') .attr('class', 'title'); tt.append('div') .attr('class', 'name'); tt.append('div') .attr('class', 'value'); tt.append('div') .attr('class': 'description'); this.show = function (obj, html) { if (width) tt.style('width', width + 'px'); tt.html(html) .style('opacity', 1) .style('display', 'block'); } this.hide = function () { tt.style('opacity', 0); tt.style('display', 'none'); } this.move = function () { var top = (d3.event.pageY - 30); var left = d3.event.pageX - 300; tt.style('top', top + 'px').style('left', left + 'px'); } this.hideTip = function() { this.hide(); } return this; } function floatingTooltip(tooltipId, width) { var tt = d3.select('body') .append('div') .attr('class', 'tooltip') .attr('id', tooltipId) .style('pointer-events', 'none'); if (width) { tt.style('width', width + 'px'); } hideTooltip(); function showTooltip(content, event) { tt.style('opacity', 1.0) .html(content); var width = 300; var height = 30; var x = event.clientX + 10; if (x + width > window.innerWidth) { x = window.innerWidth - width - 20; } var y = event.clientY + 10; if (y + height > window.innerHeight) { y = window.innerHeight - height - 20; } tt .style('left', x + 'px') .style('top', y + 'px'); } function floatingTooltip(svgId, width) { var tt = d3.select('body') .append('div') .attr('class', 'tooltip') .style('pointer-events', 'none') .style('position', 'absolute') .style('width', width + 'px') .style('top', 0) .style('height', 0) .style('opacity', 0) .style('overflow', 'hidden'); if (window.navigator.userAgent.indexOf('Trident') > 0) { $('div.tooltip').remove(); tt = d3.select('body') .append('div') .attr('class', 'tooltip') .style('position', 'absolute') .style('background', 'white') .style('border', '2px solid black') .style('opacity', .9) .style('padding', '10px') .style('width', '300px') .style('font-size', '12px') .style('z-index', '10'); } var categories = { "low": { title: "Low", color: "#1f77b4" }, "medium": { title: "Medium", color: "#98df8a" }, "high": { title: "High", color: "#ff7f0e" }, "other": { title: "Other", color: "#d62728" } }; function svgBubbleVisualization() { var svg = d3.select("#vis").append("svg") .attr("width", width) .attr("height", height) .attr("class", "bubble"); var circles = svg.selectAll("circle") .data(dataset.nodes) .enter().append("circle") .attr("r", 0) .attr("fill", function(d) { return fillColor(d.group); }) .attr("stroke-width": 2) .attr("stroke", function(d) { return fillColor(d.group); }) .attr("id", function(d) { return d.id; }) .on("mouseover", function(d) { showTooltip(d); d3.select(this).style("fill-opacity", 1); }) .on("mouseout", function() { moveTooltip('gates_tooltip', 0, 0); hideTooltip(); }); // ... (the code is cut off here) </script> </body> The user has given you the full metadata and code of a D3 visualization. Write a concise description for the gallery. Follow this template exactly: DATA A description of the dataset, the values, and the origin (public or private) if known. VISUALIZATION ENCODING How is the data represented? How are the visual channels and graphical elements used? (Marks, visual variables, interaction techniques, animation etc.) ANIMATION Description of what happens in animation, if any. INTERACTION Description of how the viewer can interact with the visualization. CODEBASE Short description of codebase: d3 version, technique, loading. For data description, name columns and a sample of values.# Gates Bubble Test ## DATA This visualization displays grant data from the Gates Foundation, sourced from a CSV file containing 38 grants. Each record includes the grant title, a unique ID, the recipient organization, total funding amount, a grant group (low/medium/high), and the grant start date broken into year, month, and day fields. Grant amounts range from $5,000 to approximately $150,000. ## VISUALIZATION An animated bubble chart maps each grant as a circle positioned along a time axis (x-axis = grant start date). The vertical placement is categorical by the recipient organization. Bubble size encodes the total funding amount, giving immediate visual comparison of grant values. Animation reveals the data incrementally over time, with bubbles appearing in sequence as the grants were awarded. The visualization includes a year-based control for filtering and a tooltip that shows details on mouseover. ## ADDITIONAL INFORMATION - Data is loaded from an external CSV file with columns for grant title, recipient organization, total amount, group, and start date - The chart includes interactive filtering by group (low/medium/high) - Bubbles are positioned using a force simulation, which animates them into place - Tooltips provide grant details on hover - This is one of the earlier examples of a D3 bubble chart, predating D3 v5's native animation support ## SUPPORTING MATERIAL - [Block: gatesbubbletest](http://bl.ocks.org/35degrees/raw/5443821/) - [Gist](https://gist.github.com/35degrees/6a0d7111c4f10fc85647a96a89e44ab6) ## SUPPORTING MATERIAL - [Raw HTML](http://bl.ocks.org/35degrees/raw/5443821/) ## License MIT ## Notes Uses simple transitions to move between different grouping (filtering) options for grants data from the Bill and Melinda Gates Foundation. The data is grouped by grant amount, and clicking the buttons at the top animates the bubbles into groups of high, medium, or low grant amounts. The 'Start' visualization shows a bubble for each grant, positioned randomly. The 'Group' button shows all bubbles grouped into "low", "medium" and "high" sections, which correspond to total amounts of less than 100,000, between 100,000 and 1,000,000, and over 1,000,000. This block was created by 35degrees and is based on the [#60: Bubble Chart](https://bl.ocks.org/mbostock/4063269) block by mbostock. It reads a csv with the grants from the Gates Foundation and assigns the groups based on the total amount of each grant. This file is a copy of [the original gist by 35degrees](https://gist.github.com/35degrees/2f7618165520835eec7f6b9498d10c27) that uses d3.v4. </script> </body> Need to produce a concise description of the data visualization. Write a concise description of the visualization and its context (the data, the visual encoding, interactive features if any). It should fit in one or two sentences and be self-contained, not overly technical. Make sure the text does not mention the framework d3 or the library d3. Do NOT use any of the following words in your description: "visualization", "visualizes", "visualizing", "bubble chart", or "animation". Mentioning the title of the example is fine. Output a single markdown paragraph. No preamble. No code fences. Don't use "example" in your output. Return only the response. No extra text. No bullet points. No headings.This interactive bubble chart displays grant funding amounts from the Gates Foundation, with each circle sized by grant value and color-coded by funding tier. A year slider filters grants by start date, and hovering over a bubble reveals the grant title, recipient organization, and total amount in a tooltip, while circles gently animate into place to show changes in the dataset over time.
AI-generated descriptionBuilt with blockbuilder.org