This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var svg = d3.select('svg'), | |
width = +svg.attr('width'), | |
height = +svg.attr('height'), | |
radius = 32 | |
var circles = d3.range(9).map(function () { | |
return { | |
x: Math.round(Math.random() * (width - radius * 2) + radius), | |
y: Math.round(Math.random() * (height - radius * 2) + radius) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// x and y of each triangle point | |
var trianglePoints = [ | |
[75, 0], | |
[0, 150], | |
[150, 150] | |
]; | |
var w = +d3.select('svg').attr('width') | |
var h = +d3.select('svg').attr('height') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var data = [ | |
{ // 0 | |
ref: 'h1', // top horizontal line | |
x1: 0, y1: 0, // use 0 for start, 0.5 for midway, and 1 for end | |
x2: 1, y2: 0, | |
}, | |
{ // 1 | |
ref: 'h2', // mid horizontal line | |
x1: 0, y1: 0.5, | |
x2: 1, y2: 0.5, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var data = [ | |
{ name: '01', group: 'one', value: 55 }, | |
{ name: '02', group: 'two', value: 21 }, | |
{ name: '03', group: 'two', value: 55 }, | |
{ name: '04', group: 'one', value: 89 }, | |
{ name: '05', group: 'one', value: 144 }, | |
{ name: '06', group: 'two', value: 144 }, | |
{ name: '07', group: 'one', value: 233 }, | |
{ name: '08', group: 'one', value: 377 }, | |
{ name: '09', group: 'two', value: 89 } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var width = window.innerWidth | |
var height = window.innerHeight | |
var svg = d3.select('svg') | |
.attr('width', width) | |
.attr('width', height) | |
var g = svg.select('#vis') | |
// create 50 items that have x and y uniformly random | |
var data = d3.range(50).map(function (n) { | |
return { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
// connect with MakeyMakey | |
var body = d3.select('body') | |
var quote = d3.select('h1#quote') | |
var author = d3.select('h3#author') | |
// background colours for each data file | |
var colours = { | |
space: '#FDBB30', | |
left_arrow: '#ec008c', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function render(nodes) { | |
var svg = d3.select('svg') | |
var width = +svg.attr('width') | |
var height = +svg.attr('height') | |
var vis = svg.select('g.vis') | |
var axis = svg.select('g.axis') | |
var f = d3.format('.2f') | |
var xScale = d3.scaleLinear() | |
.domain([0, 100]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var render = (function () { | |
var axis = [25, 50, 75, 100] | |
var sqrtScale = d3.scaleSqrt() | |
.domain([0, 100]) | |
.range([0, 200]) | |
var svg = d3.select('svg') | |
var vis = svg.select('#vis') | |
var width = +svg.attr('width') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// data is an object literal | |
var data = { | |
'key_1': 10, | |
'key_2': 20, | |
'key_3': 30, | |
'key_4': 40, | |
'key_5': 50 | |
} | |
// we create a nested array of the keys and map them with the values |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var render = (function () { | |
var svg = d3.select('svg') | |
var vis = svg.select('#vis') | |
var width = +svg.attr('width') | |
var height = +svg.attr('height') | |
var xScale = d3.scaleLinear() | |
.domain([0, 100]) | |
.range([0, width]) |