Skip to content

Instantly share code, notes, and snippets.

@biovisualize
biovisualize / index.html
Created September 11, 2011 12:07
Download generated SVG with preview (from mbostock)
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js"></script>
<title>Download SVG</title>
<style type="text/css">
a{
cursor: pointer;
text-decoration: underline;
color: black;
@enjalot
enjalot / index.html
Created December 20, 2011 21:53
masking with external svg elements
<html>
<head>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js?2.6.0"></script>
</head>
<body>
<svg>
<defs>
<mask id="rekt">
<g id="rrr">
@mbostock
mbostock / .block
Last active March 10, 2024 07:21
Mitchell’s Best-Candidate
license: gpl-3.0
redirect: https://observablehq.com/@mbostock/best-candidate-circles
@sheymann
sheymann / export_plot.R
Created April 16, 2012 16:01
R tip: Export a ggplot plot in PDF, EPS and PNG files
ExportPlot <- function(gplot, filename, width=2, height=1.5) {
# Export plot in PDF and EPS.
# Notice that A4: width=11.69, height=8.27
ggsave(paste(filename, '.pdf', sep=""), gplot, width = width, height = height)
postscript(file = paste(filename, '.eps', sep=""), width = width, height = height)
print(gplot)
dev.off()
png(file = paste(filename, '_.png', sep=""), width = width * 100, height = height * 100)
print(gplot)
dev.off()
@vitch
vitch / apply-styles.css
Created August 1, 2012 13:44
SVG background images on d3 fills
#graph svg g.us rect
{
fill: url(#tile-us) #cccccc;
}
#graph svg g.worldwide rect
{
fill: url(#tile-ww) #cccccc;
}
@mbostock
mbostock / README.md
Last active June 7, 2023 18:33
Underscore’s Equivalents in D3

Collections

each(array)

Underscore example:

_.each([1, 2, 3], function(num) { alert(num); });
@mbostock
mbostock / .block
Last active November 26, 2018 16:41 — forked from mbostock/.block
Rainbow Worm
license: gpl-3.0
redirect: https://beta.observablehq.com/@mbostock/rainbow-worm
@mbostock
mbostock / .block
Last active February 26, 2019 22:35
Rotating Voronoi
license: gpl-3.0
redirect: https://observablehq.com/@mbostock/rotating-voronoi
@nbremer
nbremer / .block
Last active April 9, 2024 08:43
Self Organizing Map - Hexagonal Heatmap - Lines
license: mit
@mbostock
mbostock / .block
Last active October 24, 2023 08:48
Drag + Zoom
license: gpl-3.0
redirect: https://observablehq.com/@d3/drag-zoom