Skip to content

Instantly share code, notes, and snippets.

@ninestar09
Created February 25, 2016 00:26
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 ninestar09/4041643c56cf6d03effe to your computer and use it in GitHub Desktop.
Save ninestar09/4041643c56cf6d03effe to your computer and use it in GitHub Desktop.
path
{"description":"path","endpoint":"","display":"svg","public":true,"require":[],"fileconfigs":{"_.md":{"default":true,"vim":false,"emacs":false,"fontSize":12},"config.json":{"default":true,"vim":false,"emacs":false,"fontSize":12},"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"inlet.svg":{"default":true,"vim":false,"emacs":false,"fontSize":12},"path":{"default":true,"vim":false,"emacs":false,"fontSize":12},"path.js":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"fullscreen":false,"play":false,"loop":false,"restart":true,"autoinit":true,"pause":true,"loop_type":"period","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"editor_editor":{"coffee":false,"vim":false,"emacs":false,"width":528,"height":570,"hide":false},"thumbnail":"http://i.imgur.com/7uig89c.png","ajax-caching":true}
var svg = d3.select("svg");
var data1 = d3.range(38);
var rects = svg.selectAll("rect")
.data(data1);
//var colorScale = d3.scale.category20();
/*
var colorScale = d3.scale.ordinal()
.range(["#540069",
"#0033FF",
"#00C2FF",
"#831010"
]);
*/
var colorScale = d3.scale.linear()
.domain([d3.min(data1), d3.max(data1)])
//.interpolate(d3.interpolateHsl)
//.interpolate(d3.interpolateLab)
.interpolate(d3.interpolateHcl)
.range(["#007AFF", "#FFF500"]);
rects.enter()
.append("rect")
.attr({
width: 12,
height: 100,
y: 100,
x: function(d,i) {
return i * 13 + 115;
},
fill: function(d,i) {
return colorScale(d);
}
})
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
var svg = d3.select("svg");
var data = [{x:0, y:8},
{x:10, y:22},
{x:20, y:20},
{x:30, y:80},
{x:40, y:34},
{x:50, y:54},
{x:60, y:54},
{x:70, y:9},
{x:80, y:128},
{x:90, y:12}
];
var line = d3.svg.line()
.x(function(d) {
return d.x;
})
.y(function(d) {
return d.y;
});
var group = svg.append("g").attr("transform", "translate("+[50,50]+")")
var path = group.selectAll("path")
.data([data])
.enter()
.append("path")
.attr({
d: line,
fill: "none",
stroke: "#0a0a0a"
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment