Skip to content

Instantly share code, notes, and snippets.

@mforando
Created July 20, 2017 01:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mforando/00940247849157d0b2dac2b789d1473d to your computer and use it in GitHub Desktop.
Save mforando/00940247849157d0b2dac2b789d1473d to your computer and use it in GitHub Desktop.
fresh block
license: mit
BillID Value Random
A193 3 0.12
S266 3 0.99
S290 3 0.62
S474B 3 0.19
S576 3 0.35
S783 4 0.91
A297A 5 0.57
S898 5 0.48
S1033 6 0.44
S1206 6 0.96
S1241A 6 0.81
A438A 9 0.82
A492 9 0.56
A560 9 0.08
S1331 9 0.45
A1015 10 0.60
A1043 10 0.93
A1190A 11 0.62
A1198 11 0.03
A1219 11 0.26
A1319 11 0.28
S1818 11 0.94
S1887 11 0.20
A1486 12 0.65
A1529A 12 0.26
A1532 12 0.60
A1647 12 0.89
S2099 12 0.86
S2162A 12 0.73
S2191 12 0.99
S2247 12 0.89
S2248 12 0.08
S2273 12 0.97
A1842B 13 0.43
S2495 13 0.48
S2496 13 0.82
S2498 13 0.58
S2639 13 0.19
A1964 17 0.53
A2310 17 0.49
A2379 18 0.41
A2437 20 0.98
A2441 20 0.54
A2460 20 0.07
A2526A 20 0.86
A2539 20 0.95
S3330 20 0.14
A2733A 23 0.24
A2734 23 0.84
A2924 23 0.28
S3570B 24 0.33
S3661 25 0.87
S3662 25 0.50
S3663 25 0.60
S3696A 25 0.69
S3867A 27 0.93
A3991A 30 0.86
S3939 30 0.40
S3942 30 0.97
A4053 32 0.56
A4472 33 0.97
A4611B 34 0.55
A4738 34 0.77
A4836 34 0.31
A5004 37 0.17
A5132 37 0.75
A5159A 37 0.91
A5175A 37 0.46
A5179 37 0.95
A5279 38 0.18
A5475 40 0.55
A5757 46 0.13
A5963B 48 0.99
A6044A 52 0.68
S4611A 53 0.28
A6089 54 0.88
A6139 54 0.41
S4741 58 0.58
S4840 62 0.75
S5016A 65 0.95
A6408 66 0.94
A6549A 68 0.35
A6820 80 0.36
S5342 81 0.54
A7107 100 0.99
A7108 100 0.46
A7203 102 0.94
S5584B 108 0.99
S5588 108 0.76
S5661B 114 0.80
S5662A 114 0.10
S5670 114 0.03
S5870 124 0.83
A7672 128 0.92
S5949 128 0.07
A7688 129 0.31
S5998 130 0.97
A7748 131 0.51
S6078 131 0.16
S6196 131 0.07
S6364 131 0.15
S6383 131 0.49
A7763 135 0.75
A7775 135 0.99
A7842 137 0.11
A8022 145 0.99
A8077 145 0.40
S6547 152 0.26
S6559 153 0.93
A8338 160 0.13
S6726 166 0.34
A8469 167 0.98
S6768 167 0.08
S6781 167 0.60
S6795 169 0.96
S6802 169 0.28
A8523 170 0.91
A8538 171 0.51
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<script src="https://d3js.org/d3.v4.min.js"></script>
<script src="https://d3js.org/d3-selection-multi.v1.min.js"></script
<style>
body { margin:25;position:fixed;top:0;right:0;bottom:0;left:0; }
</style>
</head>
<body>
<div>
<h3>Annual Legislation</h3>
</div>
</body>
<body>
<script>
var width = 750;
var height = 250;
var margin = {top: 20, right: 10, bottom: 20, left: 10};
var offset = 50;
var svg = d3.select("body").append("svg")
.attr("width", width)
.attr("height", height);
d3.csv("BillData2.csv", function(err, data) {
//set range of scale
var x = d3.scaleLinear().rangeRound([0+offset, width-offset]);
//set domain of scale
x.domain(d3.extent(data, function(d,i) { return Number(data[i].Value); }));
var simulation = d3.forceSimulation(data)
.force("x", d3.forceX(function(d,i) { return x(Number(data[i].Value)); }).strength(1))
.force("y", d3.forceY(height / 2))
.force("collide", d3.forceCollide(function(d,i) { return data[i].Random*11; }))
.stop();
//console.log(data)
for (var i = 0; i < 120; ++i) simulation.tick();
var color = d3.scaleOrdinal(d3.schemeCategory10);
svg.selectAll("body").append("g").data(data).enter()
.append("circle")
.attrs({
r: 5,
cx: function(d,i) {return x(data[i].Value);},
cy: height/2})
.transition()
.ease(d3.easeElastic)
.duration(2000)
.delay(function(d,i) { return i*3+400;})
.attr("r", function(d,i) { return data[i].Random*10; })
.attr("cx", function(d,i) { return data[i].x; })
.attr("cy", function(d,i) { return data[i].y; })
.attr("stroke","white");
svg.selectAll("circle")
.transition()
.delay(function(d,i){return 1250+Math.random()*500;})
.ease(d3.easeQuadInOut)
.style("fill", function(d,i) {return color(i)}) //"rgb(103,0,117)"
;
var xAxis = d3.axisBottom(x);
d3.select('svg').append('g')
.attr('transform', 'translate(0, '+margin.top+')')
.transition()
.call(xAxis);
console.log(data)
})
</script>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment