d3-bboxCollide coupled with requestAnimationFrame
and SVG filters to create a bonfire.
<html> | |
<head> | |
<style> | |
path.graticule { | |
fill: none; | |
stroke-width: 1; | |
stroke: #9A8B7A; | |
} | |
path.graticule.outline { | |
fill: none; |
function circlePath(radius) { | |
let arc = d3.arc().outerRadius(radius); | |
return arc({ startAngle: 0, endAngle: 8 }) | |
} | |
function rectPath(width,height) { | |
return "M0,0L" + width + ",0L" + width + "," + height + "L0," + height + "Z" | |
} | |
function linePath(x1,x2,y1,y2) { |
d3-bboxCollide using forceSimulation tied to requestAnimationFrame
to create new nodes and decrease the value (and hence size) of existing nodes to create a kind of guitar hero receding viz.
d3-bboxCollide coupled with requestAnimationFrame
and SVG filters to create a bonfire.
d3-bboxCollide allows for rectangular collision detection. This means we can do word cloud-like visualizations with more rules and constraints. In this case, the word clouds are split into columns based on speaker and laid out down the y-axis based on the segment of the debate for the term density of that word.
The data comes from the first Presidential debate of 2016, processed using Voyant Tools with custom stop words removed and then processed for term density into the 20 bins.
d3-bboxCollide provides bounding box collision detection for d3.forceSimulation
. This is useful for label adjustment or rectangular nodes. Each node receives a bounding box array of a top right and bottom left corner of that node relative to its x position. In the case of this dataset, that size is based on the length of the word in the source dataset.
A function for calculating this array based off the data is passed into the d3.bboxCollide
function, which is later passed as a "collide" constraint in your force settings.
var collide = d3.bboxCollide(function (d,i) {
return [[-d.value * 10, -d.value * 5],[d.value * 10, d.value * 5]]
})
d3.forceSimulation
bounding box collision detection. This is useful for label adjustment or rectangular nodes. Each node receives a bounding box array of a top right and bottom left corner of that node relative to its x position. In the case of this dataset, that size is based on the length of the word in the source dataset.
A function for calculating this array based off the data isis passed into the forceRectCollide function, which is later passed as a "collide" constraint in your force settings.
var collide = d3.forceRectCollide(function (d,i) {
var hw = halfWidth(d)
if (i%3 === 0) {
return [[-hw / 2, -hw],[hw / 2, hw]]
}
// https://d3js.org/d3-force/ Version 1.0.0. Copyright 2016 Mike Bostock. | |
(function (global, factory) { | |
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('d3-quadtree'), require('d3-collection'), require('d3-dispatch'), require('d3-timer')) : | |
typeof define === 'function' && define.amd ? define(['exports', 'd3-quadtree', 'd3-collection', 'd3-dispatch', 'd3-timer'], factory) : | |
(factory((global.d3 = global.d3 || {}),global.d3,global.d3,global.d3,global.d3)); | |
}(this, function (exports,d3Quadtree,d3Collection,d3Dispatch,d3Timer) { 'use strict'; | |
function center(x, y) { | |
var nodes; |
// https://d3js.org/d3-force/ Version 1.0.0. Copyright 2016 Mike Bostock. | |
(function (global, factory) { | |
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('d3-quadtree'), require('d3-collection'), require('d3-dispatch'), require('d3-timer')) : | |
typeof define === 'function' && define.amd ? define(['exports', 'd3-quadtree', 'd3-collection', 'd3-dispatch', 'd3-timer'], factory) : | |
(factory((global.d3 = global.d3 || {}),global.d3,global.d3,global.d3,global.d3)); | |
}(this, function (exports,d3Quadtree,d3Collection,d3Dispatch,d3Timer) { 'use strict'; | |
function center(x, y) { | |
var nodes; |