This examples demonstrates how to use D3's brush component to implement focus + context zooming. Click and drag in the small chart below to pan or zoom.
This file contains 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
# coding: utf-8 | |
# requires: pattern http://www.clips.ua.ac.be/pages/pattern | |
from pattern.web import * | |
import csv | |
import sys | |
# yeah I know | |
reload(sys) | |
sys.setdefaultencoding("utf-8") |
Brushing makes more sense for quantitative dimensions. It’s possible to use a brush to select categorical values, as shown here, though I’d recommend using per-value toggles instead. This way, users can pick arbitrary sets of values, rather than being forced to pick contiguous ranges.
Very simple example of using D3 transitions to move some circles and change their colors
This file contains 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Testing d3.js in Leaflet.js</title> | |
<link rel="stylesheet" href="leaflet.css"></link> | |
<script src="http://mbostock.github.com/d3/d3.v2.js?2.8.1"></script> | |
<script src="http://cdn.leafletjs.com/leaflet-0.5/leaflet.js"></script> | |
<style type="text/css"> | |
svg , g |
This file contains 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
// Turning an angle into a point on a unit | |
// circle and then back again | |
// convert from degrees to radians | |
D2R = Math.PI / 180; | |
// convert from radians to degrees | |
R2D = 180 / Math.PI; | |
// our angle | |
angle = 30; |
This file contains 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
<!DOCTYPE html> | |
<meta charset="utf-8"> | |
</style> | |
<body> | |
<script src="http://d3js.org/d3.v3.min.js"></script> | |
<script> | |
D2R = Math.PI / 180; |
This file contains 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
<!DOCTYPE html> | |
<meta charset="utf-8"> | |
</style> | |
<body> | |
<script src="http://d3js.org/d3.v3.min.js"></script> | |
<script> | |
D2R = Math.PI / 180; |
This file contains 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
root = exports ? this | |
Bubbles = () -> | |
# standard variables accessible to | |
# the rest of the functions inside Bubbles | |
width = 900 | |
height = 510 | |
data = [] | |
node = null |
Using d3.geo.tile to display raster image tiles underneath some TopoJSON vectors, and d3.behavior.zoom for pan & zoom.