[ Launch: ratings ] 6468024 by agconti
-
-
Save agconti/6468024 to your computer and use it in GitHub Desktop.
ratings
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":"ratings","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}},"fullscreen":false,"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,"inline-console":false,"thumbnail":"http://i.imgur.com/MNw9eSD.png"} |
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 data = [1, 1, 2, 4,5]; | |
var h = 359; | |
var w = 266; | |
var bpad = 1; | |
//Create SVG element | |
//var svg = d3.select("body") | |
// .append("svg") | |
// .attr({ | |
// "width": w, | |
// "height": h | |
// }); | |
//yscale | |
var yScale = d3.scale.linear() | |
.domain([0, d3.max(data)]) | |
.range([0, h]); | |
//xScale | |
var xScale =d3.scale.linear() | |
.domain([0, d3.max(data)]) | |
.range([0, w]); | |
// color scales | |
var colorscale = d3.scale.linear() | |
.domain([d3.min(data), d3.max(data)]) | |
.interpolate(d3.interpolateHcl) | |
.range(["#FF5050", "#214592"]); | |
var svg = d3.select('svg'); | |
var rects = svg.selectAll('rect') | |
.data(data); | |
rects.enter() | |
.append('rect') | |
.attr({ | |
width: function(d){return (w / data.length) - bpad;}, | |
height: function(d){return yScale(d);}, | |
y: function(d){return (h - yScale(d));}, | |
x: function(d,i){return (i * w/data.length);}, | |
fill: function(d){return colorscale(d);} | |
}); | |
//axis | |
svg.append("g") | |
.call(d3.svg.axis() | |
.scale() | |
.orient("bottom")); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment