Skip to content

Instantly share code, notes, and snippets.

View pnavarrc's full-sized avatar

Pablo Navarro pnavarrc

  • Act Now Coalition
  • Vancouver, Canada
  • 10:01 (UTC -07:00)
View GitHub Profile
@pnavarrc
pnavarrc / _.md
Created November 23, 2012 15:52
Appearing Circle
@pnavarrc
pnavarrc / index.html
Created November 25, 2012 01:48 — forked from idan/index.html
MapBox + d3
<!DOCTYPE html>
<html>
<head>
<script src='http://api.tiles.mapbox.com/mapbox.js/v0.6.4/mapbox.js'></script>
<script src='http://d3js.org/d3.v2.js?2.9.3'></script>
<link
href='http://api.tiles.mapbox.com/mapbox.js/v0.6.4/mapbox.css'
rel='stylesheet' />
<style>
body { margin:0; padding:0; }
@pnavarrc
pnavarrc / index.html
Last active December 15, 2015 02:59
Example of Drag Behavior in D3
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Drag Behavior Demo</title>
</head>
<script src="http://d3js.org/d3.v3.min.js"></script>
<body>
<script type="text/javascript">
@pnavarrc
pnavarrc / geocode.py
Last active September 20, 2023 12:43
Using Python requests and the Google Maps Geocoding API
# Using Python requests and the Google Maps Geocoding API.
#
# References:
#
# * http://docs.python-requests.org/en/latest/
# * https://developers.google.com/maps/
import requests
GOOGLE_MAPS_API_URL = 'http://maps.googleapis.com/maps/api/geocode/json'
@pnavarrc
pnavarrc / README.md
Last active December 16, 2015 23:39 — forked from mbostock/.block

This variation of a line chart demonstrates a sequence of chained transitions. Clicking on the radio buttons changes the displayed metric. First, the line transitions to the new values. Then, the axes rescale to fit the new data.

@pnavarrc
pnavarrc / README.md
Last active February 8, 2017 12:54
Automatic Label Placement

Automatic Label Placement

This example is an extension of Mike Bostock’s tutorial Lets Make a Map that implements automatic label placement using the force layout and multiple foci. The centroid of each feature will define a foci of the force. This foci will attract the label that correspond to that feature (and ignore the others). The labels will repel themselves to avoid overlapping.

References

@pnavarrc
pnavarrc / README.md
Last active September 17, 2017 12:40
Bee Anatomy

Bee Anatomy

This gist is to show how to integrate a raster image and a svg overlay to create images that show the parts of an object. In this case, I show the main parts of the bee anatomy.

The svg image was created with Inkscape. First, the raster image is inserted in the svg file to draw the shapes. Then, each path is given an id to allow its identification in the web version. For instance, the forewings, the lines and the corresponding text are given ids to allow its identification and assignment of a class in the page.

WIth D3, we use mouseover and mouseout to show and hide the elements of the same class that the selected element.

Thanks to Joost Witteveen for sharing the photo of the bee with cc Attribution license.

@pnavarrc
pnavarrc / Makefile
Last active January 9, 2021 02:39
Celestial Sphere
hygfull.csv:
curl -LO 'https://github.com/astronexus/HYG-Database/raw/master/hygfull.csv'
hyg.json: hygfull.csv
python parse-catalog.py
We couldn’t find that file to show.
@pnavarrc
pnavarrc / Makefile
Last active August 29, 2015 13:57
D3 Orthographic Projection with TopoJSON
URL = http://www.naturalearthdata.com/http//www.naturalearthdata.com/download/50m/physical/ne_50m_land.zip
ne_50m_land.zip:
curl -LO $(URL)
ne_50m_land.shp: ne_50m_land.zip
unzip ne_50m_land.zip
touch ne_50m_land.shp
land.json: ne_50m_land.shp