Skip to content

Instantly share code, notes, and snippets.

@ganeshv
ganeshv / pigpeg.js
Last active August 29, 2015 14:07
Pre-compiled parser for pigshell
parser = (function(){
/*
* Generated by PEG.js 0.7.0.
*
* http://pegjs.majda.cz/
*/
function subclass(child, parent) {
function ctor() { this.constructor = child; }
ctor.prototype = parent.prototype;
@ganeshv
ganeshv / .index.html.swp
Created September 15, 2014 12:36
India Census 2011 - Electricity vs Mobile
@ganeshv
ganeshv / README.md
Created September 2, 2014 16:15
India Census 2011 - Toilet Access

India 2011 Census - Toilet Access

Choropleth map of districts from 2011 Census data.

Usage

There are two commands: pca and hlpca, to display population data and housing data respectively. Each takes three arguments:

@ganeshv
ganeshv / README.md
Last active August 29, 2015 14:05
India Census 2011 - Sex Ratio

India 2011 Census - Sex Ratio

Choropleth map of districts from 2011 Census data.

Usage

There are two commands: pca and hlpca, to display population data and housing data respectively. Each takes three arguments:

@ganeshv
ganeshv / README.md
Last active August 29, 2015 14:05
India 2011 Census Map Mania

India 2011 Census Map Visualization

Choropleth map of districts from 2011 Census data.

Usage

There are two commands: pca and hlpca, to display population data and housing data respectively. Each takes three arguments:

@ganeshv
ganeshv / 2014-electoral-rolls3.csv
Last active August 29, 2015 14:05
India's Voter Sex Ratio
key STATE_CODE PC_NO STATE PC_NAME 18-19 Male 18-19 Female 18-19 Others Above 18 Male Above 18 Female Above 18 Others Electors with EPIC Electors with Photo
AN1 AN 1 ANDAMAN AND NICOBAR ISLANDS ANDAMAN AND NICOBAR ISLANDS 1529 1370 0 136356 121500 0 254093 254093
AP1 AP 1 ANDRA PRADESH ADILABAD 30191 20152 16 674909 686044 132 1361085 1361085
AP2 AP 2 ANDRA PRADESH PEDDAPALLE 23342 15088 19 702419 676669 93 1379181 1379181
AP4 AP 4 ANDRA PRADESH NIZAMABAD 23285 13463 5 701661 749739 64 1451464 1451464
AP5 AP 5 ANDRA PRADESH ZAHIRABAD 21456 11559 8 703663 712913 60 1416636 1416636
AP3 AP 3 ANDRA PRADESH KARIMNAGAR 24941 15453 8 755526 751194 67 1506787 1506787
AP6 AP 6 ANDRA PRADESH MEDAK 26421 14428 12 749671 737580 84 1487335 1487335
AP7 AP 7 ANDRA PRADESH MALKAJGIRI 49191 31744 20 1596146 1357475 294 2953915 2953915
AP14 AP 14 ANDRA PRADESH BHONGIR 22289 12421 7 739084 717775 44 1456903 1456903
@ganeshv
ganeshv / README.md
Last active August 29, 2015 14:04
GDP Treemap

Countrywise GDP data for 2012 obtained from Quandl visualized using the Zoomable Treemap Template

Click a cell to zoom in. Click the orange bar at the top to zoom out.

@ganeshv
ganeshv / .block
Last active June 26, 2023 12:25
Zoomable Treemap Template
license: gpl-3.0
@ganeshv
ganeshv / README.md
Last active August 29, 2015 14:04
World Map Template

World map chloropleth template

This template follows pigshell's convention for "gist templates":

  • It is supplied data using postMessage(), as a single object of the form { opts: {...}, data: [...] }
  • It posts a message to the parent with an object of the form { height: <number> } to enable the framing context to adjust the height of the iframe.
  • If the URL does not contain a hash fragment, it displays sample data from the containing gist.
@ganeshv
ganeshv / README.md
Last active October 31, 2015 15:00
Life Expectancy - Orthographic Projection

Life expectancy data for countries, obtained from Wikipedia and plotted with pigshell on an orthographic projection. The template is based on Rotate the world by Jason Davies. Colors by Cynthia Brewer

ycat http://en.wikipedia.org/wiki/List_of_countries_by_life_expectancy | hgrep -r 0 table.wikitable | table2js foo country data | iframe -o proj=orthographic -g /usr/template/d3-worldmap1

Running through the pipeline step by step:

  • ycat uses YQL to retrieve the contents of the Wikipedia page. We use ycat to jump the same-origin barrier.
  • hgrep selects HTML elements using a jQuery/CSS-like expression.
  • table2js converts the table contents into plain Javascript objects, the