[ Launch: blocks ] b07f3ab78205fd8458186a545f5ada04 by mogauvin
[ Launch: test ] 4653053 by enjalot
[ Launch: test ] 4652017 by enjalot
[ Launch: test ] 4582399 by enjalot
-
-
Save mogauvin/b07f3ab78205fd8458186a545f5ada04 to your computer and use it in GitHub Desktop.
blocks
This file contains hidden or 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
{"description":"blocks","endpoint":"","display":"svg","public":true,"require":[],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"_.md":{"default":true,"vim":false,"emacs":false,"fontSize":12},"config.json":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"period","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"tab":"edit","display_percent":0.7,"thumbnail":"http://i.imgur.com/IsM3ArI.gif","fullscreen":false,"ajax-caching":true} |
This file contains hidden or 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 lineData = [ { "x": 0, "y": 5}, { "x": 20, "y": 20}, | |
{ "x": 40, "y": 10}, { "x": 60, "y": 40}, | |
{ "x": 80, "y": 5}, { "x": 200, "y": 30}]; | |
var p = [ { "x": 1, "y": 0}, { "x": 20, "y": 20}, | |
{ "x": 40, "y": 10}, | |
{ "x": 60, "y": 40}, | |
{ "x": 80, "y": 5}, | |
{ "x": 90, "y": 50}, | |
{ "x": 96, "y": 10}, | |
{ "x": 102, "y": 19}, | |
{ "x": 109, "y": 13}, | |
{ "x": 119, "y": 19}, | |
{ "x": 132, "y": 30}, | |
{ "x": 143, "y": 41}, | |
{ "x": 149, "y": 29}, | |
{ "x": 200, "y": 80} | |
] | |
//Do some basic setup - set margins and widths for the entire graph | |
var margin = {top: 20, right:20, bottom: 30, left: 30}, | |
width = 1200 - margin.left - margin.right, | |
height = 700 - margin.top - margin.bottom; | |
//Define Scale | |
var x = d3.scale.linear() | |
.range([0, width]); | |
var y = d3.scale.linear() | |
.range([height, 0]); | |
//Define an x Axis | |
var xAxis = d3.svg.axis() | |
.scale(x) | |
.orient("bottom"); | |
//Define an y axis | |
var yAxis = d3.svg.axis() | |
.scale(y) | |
.orient("left").ticks(4); | |
var xScale = d3.scale.ordinal() | |
.domain(d3.range(10)) | |
.rangeRoundBands([0, width],0); | |
var yScale = d3.scale.ordinal() | |
.domain(d3.range(4)) | |
.rangeRoundBands([0, height],0); | |
var svg = d3.select("body").append("svg") | |
.attr("class",'container') | |
.attr("width", width + margin.left + margin.right) | |
.attr("height", height + margin.top + margin.bottom) | |
.append("g") | |
.attr("transform", "translate(" + margin.left + "," + margin.top + ")"); | |
x.domain([0,d3.max(p, function(d) { return d.x; })]); | |
y.domain([0,d3.max(p, function(d) { return d.y; })]); | |
svg.selectAll("rect") | |
.data(p) | |
.enter() | |
.append("rect") | |
.attr("x", function(d, i) { | |
return xScale(i); | |
}) | |
.attr("y", function(d,i) { | |
return 0; | |
}) | |
.attr("width", xScale.rangeBand()) | |
.attr("height", yScale.rangeBand()) | |
.attr("fill", "green"). | |
attr('stroke','red'); | |
svg.append("g") | |
.attr("class", "x axis") | |
.attr("transform", "translate(0," + height + ")") | |
.call(xAxis); | |
svg.append("g") | |
.attr("class", "y axis") | |
.call(yAxis); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment