Interactive chord diagram in D3

This post revisits the taxi ride data to make an interactive circos diagram in D3. Originally presented in 2009 by Martin Krzywinsk in his paper "Circos: an Information Aesthetic for Comparative Genomics.", it has become widely used and appreciated outside of the genomic/bioinformatic community. Its aesthetics and features effectively display relationships between different entities or patterns in periodic data. For the taxi data, it's actually quite simple to create a circos Chord diagram by tweaking existing codes shared by users (i.e, AndrewRP, nbremer) on https://bl.ocks.org/ , plus I will break down the essential elements of the chord diagram.

March 26, 2018 - 10 minute read -
D3, Data visualization, Chord diagram
18people leaving Alphabet CityAlphabet City2people leaving AstoriaAstoria32people leaving Battery Park CityBattery Park City1people leaving Bed-StuyBed-Stuy1people leaving Boerum HillBoerum Hill2people leaving Brooklyn HeightsBrooklyn Heights1people leaving Brooklyn Navy YardBrooklyn Navy Yard2people leaving BushwickBushwick14people leaving Central ParkCentral Park79people leaving ChelseaChelsea3people leaving Cobble Hill Historic DistrictCobble Hill Historic District1people leaving CoronaCorona4people leaving DUMBODUMBO227people leaving Diamond DistrictDiamond District2people leaving Downtown BrooklynDowntown Brooklyn31people leaving East ElmhurstEast Elmhurst11people leaving East HarlemEast Harlem33people leaving East VillageEast Village1people leaving ElmhurstElmhurst3people leaving Five PointsFive Points47people leaving Flatiron BuildingFlatiron Building4people leaving Fort GreeneFort Greene1people leaving GowanusGowanus2people leaving GreenpointGreenpoint72people leaving Greenwich VillageGreenwich Village6people leaving Hamilton HeightsHamilton Heights3people leaving HarlemHarlem110people leaving Hell's KitchenHell's Kitchen1people leaving InwoodInwood0people leaving Jackson HeightsJackson Heights1people leaving JamaicaJamaica24people leaving Kips BayKips Bay100people leaving KoreatownKoreatown2people leaving LICLIC108people leaving Lenox HillLenox Hill3people leaving Lincoln SquareLincoln Square1people leaving Lincoln TowersLincoln Towers5people leaving Little ItalyLittle Italy28people leaving Lower East SideLower East Side1people leaving ManhattanvilleManhattanville4people leaving Midtown WestMidtown West7people leaving Morningside HeightsMorningside Heights44people leaving Murray HillMurray Hill5people leaving NoHoNoHo9people leaving NoHo Historic DistrictNoHo Historic District29people leaving North BeachNorth Beach2people leaving Park SlopePark Slope3people leaving Prospect HeightsProspect Heights0people leaving Rego ParkRego Park21people leaving Rose HillRose Hill17people leaving SoHoSoHo25people leaving Southbridge TowersSouthbridge Towers1people leaving SteinwaySteinway4people leaving Sunnyside GardensSunnyside Gardens45people leaving TribecaTribeca83people leaving Tudor CityTudor City6people leaving University VillageUniversity Village167people leaving Upper East SideUpper East Side171people leaving Upper West SideUpper West Side3people leaving Washington HeightsWashington Heights25people leaving Washington Square VillageWashington Square Village8people leaving WilliamsburgWilliamsburg0people leaving WoodsideWoodside68people leaving YorkvilleYorkvilleBattery Park City → Alphabet City: 1 Alphabet City → Battery Park City: 0Alphabet City → Bushwick: 1 Bushwick → Alphabet City: 0Central Park → Alphabet City: 1 Alphabet City → Central Park: 0Alphabet City → East Harlem: 1 East Harlem → Alphabet City: 0Kips Bay → Alphabet City: 1 Alphabet City → Kips Bay: 0Rose Hill → Alphabet City: 1 Alphabet City → Rose Hill: 0Alphabet City → SoHo: 1 SoHo → Alphabet City: 0Alphabet City → Southbridge Towers: 1 Southbridge Towers → Alphabet City: 0Alphabet City → Upper West Side: 1 Upper West Side → Alphabet City: 0Alphabet City → Washington Heights: 1 Washington Heights → Alphabet City: 0Battery Park City → Astoria: 1 Astoria → Battery Park City: 0Astoria → Corona: 1 Corona → Astoria: 0Hell's Kitchen → Astoria: 1 Astoria → Hell's Kitchen: 0Steinway → Astoria: 1 Astoria → Steinway: 0Astoria → Upper East Side: 1 Upper East Side → Astoria: 0Upper West Side → Astoria: 1 Astoria → Upper West Side: 0Battery Park City → DUMBO: 1 DUMBO → Battery Park City: 0Battery Park City → Fort Greene: 1 Fort Greene → Battery Park City: 0Murray Hill → Battery Park City: 1 Battery Park City → Murray Hill: 0NoHo Historic District → Battery Park City: 1 Battery Park City → NoHo Historic District: 0Battery Park City → Park Slope: 1 Park Slope → Battery Park City: 0Battery Park City → Prospect Heights: 1 Prospect Heights → Battery Park City: 0Rose Hill → Battery Park City: 1 Battery Park City → Rose Hill: 0Harlem → Bed-Stuy: 1 Bed-Stuy → Harlem: 0Kips Bay → Bed-Stuy: 1 Bed-Stuy → Kips Bay: 0Bed-Stuy → Upper East Side: 1 Upper East Side → Bed-Stuy: 0Upper West Side → Bed-Stuy: 1 Bed-Stuy → Upper West Side: 0Boerum Hill → Greenpoint: 1 Greenpoint → Boerum Hill: 0East Elmhurst → Brooklyn Heights: 1 Brooklyn Heights → East Elmhurst: 0Brooklyn Heights → Greenwich Village: 1 Greenwich Village → Brooklyn Heights: 0Fort Greene → Brooklyn Navy Yard: 1 Brooklyn Navy Yard → Fort Greene: 0Upper East Side → Brooklyn Navy Yard: 1 Brooklyn Navy Yard → Upper East Side: 0Flatiron Building → Bushwick: 1 Bushwick → Flatiron Building: 0Fort Greene → Bushwick: 1 Bushwick → Fort Greene: 0Hell's Kitchen → Bushwick: 1 Bushwick → Hell's Kitchen: 0Lower East Side → Bushwick: 1 Bushwick → Lower East Side: 0Bushwick → North Beach: 1 North Beach → Bushwick: 0Williamsburg → Bushwick: 1 Bushwick → Williamsburg: 0Central Park → Chelsea: 1 Chelsea → Central Park: 0Central Park → East Harlem: 1 East Harlem → Central Park: 0Five Points → Central Park: 1 Central Park → Five Points: 0Central Park → Fort Greene: 1 Fort Greene → Central Park: 0Greenwich Village → Central Park: 1 Central Park → Greenwich Village: 0Koreatown → Central Park: 1 Central Park → Koreatown: 0Central Park → Lenox Hill: 1 Lenox Hill → Central Park: 0Central Park → Little Italy: 1 Little Italy → Central Park: 0Central Park → Morningside Heights: 1 Morningside Heights → Central Park: 0Central Park → Murray Hill: 1 Murray Hill → Central Park: 0NoHo Historic District → Central Park: 1 Central Park → NoHo Historic District: 0North Beach → Central Park: 1 Central Park → North Beach: 0Central Park → Tribeca: 1 Tribeca → Central Park: 0Yorkville → Central Park: 1 Central Park → Yorkville: 0Chelsea → Downtown Brooklyn: 1 Downtown Brooklyn → Chelsea: 0East Harlem → Chelsea: 1 Chelsea → East Harlem: 0Chelsea → Hamilton Heights: 1 Hamilton Heights → Chelsea: 0Lincoln Square → Chelsea: 1 Chelsea → Lincoln Square: 0Little Italy → Chelsea: 1 Chelsea → Little Italy: 0Chelsea → Manhattanville: 1 Manhattanville → Chelsea: 0Chelsea → Midtown West: 1 Midtown West → Chelsea: 0Chelsea → Morningside Heights: 1 Morningside Heights → Chelsea: 0Rose Hill → Chelsea: 1 Chelsea → Rose Hill: 0Chelsea → Southbridge Towers: 1 Southbridge Towers → Chelsea: 0Chelsea → University Village: 1 University Village → Chelsea: 0Cobble Hill Historic District → DUMBO: 1 DUMBO → Cobble Hill Historic District: 0Cobble Hill Historic District → Prospect Heights: 1 Prospect Heights → Cobble Hill Historic District: 0Tribeca → Cobble Hill Historic District: 1 Cobble Hill Historic District → Tribeca: 0Upper East Side → Cobble Hill Historic District: 1 Cobble Hill Historic District → Upper East Side: 0East Harlem → Corona: 1 Corona → East Harlem: 0Downtown Brooklyn → DUMBO: 1 DUMBO → Downtown Brooklyn: 0Greenwich Village → DUMBO: 1 DUMBO → Greenwich Village: 0DUMBO → Lower East Side: 1 Lower East Side → DUMBO: 0DUMBO → Tribeca: 1 Tribeca → DUMBO: 0Diamond District → Downtown Brooklyn: 1 Downtown Brooklyn → Diamond District: 0Hamilton Heights → Diamond District: 1 Diamond District → Hamilton Heights: 0Diamond District → Inwood: 1 Inwood → Diamond District: 0Diamond District → Jackson Heights: 1 Jackson Heights → Diamond District: 0Diamond District → LIC: 1 LIC → Diamond District: 0Diamond District → Lincoln Towers: 1 Lincoln Towers → Diamond District: 0Morningside Heights → Diamond District: 1 Diamond District → Morningside Heights: 0NoHo → Diamond District: 1 Diamond District → NoHo: 0Prospect Heights → Diamond District: 1 Diamond District → Prospect Heights: 0Diamond District → Rego Park: 1 Rego Park → Diamond District: 0Diamond District → Steinway: 1 Steinway → Diamond District: 0Diamond District → Sunnyside Gardens: 1 Sunnyside Gardens → Diamond District: 0Harlem → Downtown Brooklyn: 1 Downtown Brooklyn → Harlem: 0Downtown Brooklyn → Southbridge Towers: 1 Southbridge Towers → Downtown Brooklyn: 0Tudor City → Downtown Brooklyn: 1 Downtown Brooklyn → Tudor City: 0Upper West Side → Downtown Brooklyn: 1 Downtown Brooklyn → Upper West Side: 0East Elmhurst → East Harlem: 1 East Harlem → East Elmhurst: 0East Elmhurst → East Village: 1 East Village → East Elmhurst: 0East Elmhurst → Hell's Kitchen: 1 Hell's Kitchen → East Elmhurst: 0Lenox Hill → East Elmhurst: 1 East Elmhurst → Lenox Hill: 0East Elmhurst → Lower East Side: 1 Lower East Side → East Elmhurst: 0Midtown West → East Elmhurst: 1 East Elmhurst → Midtown West: 0East Elmhurst → NoHo Historic District: 1 NoHo Historic District → East Elmhurst: 0East Elmhurst → North Beach: 1 North Beach → East Elmhurst: 0East Elmhurst → Park Slope: 1 Park Slope → East Elmhurst: 0East Harlem → North Beach: 1 North Beach → East Harlem: 0University Village → East Harlem: 1 East Harlem → University Village: 0Washington Square Village → East Harlem: 1 East Harlem → Washington Square Village: 0Yorkville → East Harlem: 1 East Harlem → Yorkville: 0LIC → East Village: 1 East Village → LIC: 0North Beach → East Village: 1 East Village → North Beach: 0SoHo → East Village: 1 East Village → SoHo: 0East Village → Upper West Side: 1 Upper West Side → East Village: 0East Village → Williamsburg: 1 Williamsburg → East Village: 0East Village → Yorkville: 1 Yorkville → East Village: 0Elmhurst → Greenwich Village: 1 Greenwich Village → Elmhurst: 0Yorkville → Elmhurst: 1 Elmhurst → Yorkville: 0Five Points → Greenwich Village: 1 Greenwich Village → Five Points: 0Hell's Kitchen → Five Points: 1 Five Points → Hell's Kitchen: 0Lincoln Towers → Five Points: 1 Five Points → Lincoln Towers: 0Upper West Side → Five Points: 1 Five Points → Upper West Side: 0Washington Square Village → Five Points: 1 Five Points → Washington Square Village: 0Williamsburg → Five Points: 1 Five Points → Williamsburg: 0Yorkville → Five Points: 1 Five Points → Yorkville: 0Lower East Side → Flatiron Building: 1 Flatiron Building → Lower East Side: 0Flatiron Building → Murray Hill: 1 Murray Hill → Flatiron Building: 0Rose Hill → Flatiron Building: 1 Flatiron Building → Rose Hill: 0Flatiron Building → Southbridge Towers: 1 Southbridge Towers → Flatiron Building: 0Flatiron Building → Tribeca: 1 Tribeca → Flatiron Building: 0Fort Greene → Hell's Kitchen: 1 Hell's Kitchen → Fort Greene: 0Lower East Side → Fort Greene: 1 Fort Greene → Lower East Side: 0Prospect Heights → Fort Greene: 1 Fort Greene → Prospect Heights: 0Tribeca → Fort Greene: 1 Fort Greene → Tribeca: 0Upper East Side → Fort Greene: 1 Fort Greene → Upper East Side: 0Fort Greene → Upper West Side: 1 Upper West Side → Fort Greene: 0Lenox Hill → Gowanus: 1 Gowanus → Lenox Hill: 0Rose Hill → Gowanus: 1 Gowanus → Rose Hill: 0Gowanus → Tudor City: 1 Tudor City → Gowanus: 0Greenpoint → Hamilton Heights: 1 Hamilton Heights → Greenpoint: 0LIC → Greenpoint: 1 Greenpoint → LIC: 0Murray Hill → Greenpoint: 1 Greenpoint → Murray Hill: 0NoHo Historic District → Greenpoint: 1 Greenpoint → NoHo Historic District: 0Rose Hill → Greenpoint: 1 Greenpoint → Rose Hill: 0Tribeca → Greenpoint: 1 Greenpoint → Tribeca: 0Upper East Side → Greenpoint: 1 Greenpoint → Upper East Side: 0Williamsburg → Greenpoint: 1 Greenpoint → Williamsburg: 0Greenwich Village → Harlem: 1 Harlem → Greenwich Village: 0Greenwich Village → Jackson Heights: 1 Jackson Heights → Greenwich Village: 0Greenwich Village → Kips Bay: 1 Kips Bay → Greenwich Village: 0Lincoln Square → Greenwich Village: 1 Greenwich Village → Lincoln Square: 0Little Italy → Greenwich Village: 1 Greenwich Village → Little Italy: 0Greenwich Village → Manhattanville: 1 Manhattanville → Greenwich Village: 0Greenwich Village → Midtown West: 1 Midtown West → Greenwich Village: 0Greenwich Village → Morningside Heights: 1 Morningside Heights → Greenwich Village: 0NoHo Historic District → Greenwich Village: 1 Greenwich Village → NoHo Historic District: 0Greenwich Village → Park Slope: 1 Park Slope → Greenwich Village: 0Rose Hill → Greenwich Village: 1 Greenwich Village → Rose Hill: 0Hamilton Heights → Manhattanville: 1 Manhattanville → Hamilton Heights: 0Hamilton Heights → Morningside Heights: 1 Morningside Heights → Hamilton Heights: 0Hamilton Heights → Tribeca: 1 Tribeca → Hamilton Heights: 0Washington Heights → Hamilton Heights: 1 Hamilton Heights → Washington Heights: 0Hamilton Heights → Yorkville: 1 Yorkville → Hamilton Heights: 0Hell's Kitchen → Harlem: 1 Harlem → Hell's Kitchen: 0Lower East Side → Harlem: 1 Harlem → Lower East Side: 0Upper East Side → Harlem: 1 Harlem → Upper East Side: 0Yorkville → Harlem: 1 Harlem → Yorkville: 0Hell's Kitchen → Kips Bay: 1 Kips Bay → Hell's Kitchen: 0Hell's Kitchen → LIC: 1 LIC → Hell's Kitchen: 0Hell's Kitchen → Lincoln Towers: 1 Lincoln Towers → Hell's Kitchen: 0Hell's Kitchen → Midtown West: 1 Midtown West → Hell's Kitchen: 0Hell's Kitchen → Morningside Heights: 1 Morningside Heights → Hell's Kitchen: 0Murray Hill → Hell's Kitchen: 1 Hell's Kitchen → Murray Hill: 0Hell's Kitchen → NoHo: 1 NoHo → Hell's Kitchen: 0NoHo Historic District → Hell's Kitchen: 1 Hell's Kitchen → NoHo Historic District: 0Sunnyside Gardens → Hell's Kitchen: 1 Hell's Kitchen → Sunnyside Gardens: 0Hell's Kitchen → Williamsburg: 1 Williamsburg → Hell's Kitchen: 0Hell's Kitchen → Woodside: 1 Woodside → Hell's Kitchen: 0Inwood → Tudor City: 1 Tudor City → Inwood: 0Washington Heights → Inwood: 1 Inwood → Washington Heights: 0North Beach → Jackson Heights: 1 Jackson Heights → North Beach: 0Yorkville → Jackson Heights: 1 Jackson Heights → Yorkville: 0Koreatown → Jamaica: 1 Jamaica → Koreatown: 0Jamaica → Upper East Side: 1 Upper East Side → Jamaica: 0Upper West Side → Jamaica: 1 Jamaica → Upper West Side: 0Williamsburg → Jamaica: 1 Jamaica → Williamsburg: 0North Beach → Kips Bay: 1 Kips Bay → North Beach: 0Tribeca → Kips Bay: 1 Kips Bay → Tribeca: 0Manhattanville → Koreatown: 1 Koreatown → Manhattanville: 0Koreatown → Morningside Heights: 1 Morningside Heights → Koreatown: 0Koreatown → NoHo Historic District: 1 NoHo Historic District → Koreatown: 0Koreatown → North Beach: 1 North Beach → Koreatown: 0Koreatown → SoHo: 1 SoHo → Koreatown: 0Koreatown → Washington Square Village: 1 Washington Square Village → Koreatown: 0Murray Hill → LIC: 1 LIC → Murray Hill: 0North Beach → LIC: 1 LIC → North Beach: 0Upper East Side → LIC: 1 LIC → Upper East Side: 0Midtown West → Lenox Hill: 1 Lenox Hill → Midtown West: 0Morningside Heights → Lenox Hill: 1 Lenox Hill → Morningside Heights: 0Lenox Hill → NoHo: 1 NoHo → Lenox Hill: 0Lenox Hill → Park Slope: 1 Park Slope → Lenox Hill: 0Lenox Hill → Rose Hill: 1 Rose Hill → Lenox Hill: 0Lenox Hill → SoHo: 1 SoHo → Lenox Hill: 0Southbridge Towers → Lenox Hill: 1 Lenox Hill → Southbridge Towers: 0Lenox Hill → Steinway: 1 Steinway → Lenox Hill: 0Lenox Hill → Sunnyside Gardens: 1 Sunnyside Gardens → Lenox Hill: 0Lenox Hill → University Village: 1 University Village → Lenox Hill: 0Lenox Hill → Williamsburg: 1 Williamsburg → Lenox Hill: 0Lincoln Square → Yorkville: 1 Yorkville → Lincoln Square: 0Murray Hill → Lincoln Towers: 1 Lincoln Towers → Murray Hill: 0Upper East Side → Lincoln Towers: 1 Lincoln Towers → Upper East Side: 0Little Italy → NoHo: 1 NoHo → Little Italy: 0North Beach → Little Italy: 1 Little Italy → North Beach: 0Little Italy → Park Slope: 1 Park Slope → Little Italy: 0Little Italy → Rose Hill: 1 Rose Hill → Little Italy: 0Upper East Side → Little Italy: 1 Little Italy → Upper East Side: 0Upper West Side → Little Italy: 1 Little Italy → Upper West Side: 0Washington Heights → Little Italy: 1 Little Italy → Washington Heights: 0Lower East Side → Williamsburg: 1 Williamsburg → Lower East Side: 0Tudor City → Manhattanville: 1 Manhattanville → Tudor City: 0Upper West Side → Manhattanville: 1 Manhattanville → Upper West Side: 0North Beach → Midtown West: 1 Midtown West → North Beach: 0Tudor City → Midtown West: 1 Midtown West → Tudor City: 0Morningside Heights → Murray Hill: 1 Murray Hill → Morningside Heights: 0Morningside Heights → Upper East Side: 1 Upper East Side → Morningside Heights: 0NoHo → Murray Hill: 1 Murray Hill → NoHo: 0Murray Hill → NoHo Historic District: 1 NoHo Historic District → Murray Hill: 0Murray Hill → Rose Hill: 1 Rose Hill → Murray Hill: 0Murray Hill → University Village: 1 University Village → Murray Hill: 0Williamsburg → Murray Hill: 1 Murray Hill → Williamsburg: 0NoHo → SoHo: 1 SoHo → NoHo: 0Southbridge Towers → NoHo: 1 NoHo → Southbridge Towers: 0Tudor City → NoHo Historic District: 1 NoHo Historic District → Tudor City: 0Washington Square Village → NoHo Historic District: 1 NoHo Historic District → Washington Square Village: 0North Beach → Prospect Heights: 1 Prospect Heights → North Beach: 0North Beach → Southbridge Towers: 1 Southbridge Towers → North Beach: 0Tribeca → North Beach: 1 North Beach → Tribeca: 0North Beach → Tudor City: 1 Tudor City → North Beach: 0Williamsburg → North Beach: 1 North Beach → Williamsburg: 0Park Slope → Southbridge Towers: 1 Southbridge Towers → Park Slope: 0Upper East Side → Park Slope: 1 Park Slope → Upper East Side: 0Williamsburg → Park Slope: 1 Park Slope → Williamsburg: 0Prospect Heights → Upper East Side: 1 Upper East Side → Prospect Heights: 0Yorkville → Prospect Heights: 1 Prospect Heights → Yorkville: 0Tudor City → Rego Park: 1 Rego Park → Tudor City: 0Rose Hill → Southbridge Towers: 1 Southbridge Towers → Rose Hill: 0Upper West Side → Rose Hill: 1 Rose Hill → Upper West Side: 0SoHo → Southbridge Towers: 1 Southbridge Towers → SoHo: 0SoHo → Tudor City: 1 Tudor City → SoHo: 0University Village → SoHo: 1 SoHo → University Village: 0Southbridge Towers → Sunnyside Gardens: 1 Sunnyside Gardens → Southbridge Towers: 0Tribeca → Southbridge Towers: 1 Southbridge Towers → Tribeca: 0Sunnyside Gardens → Woodside: 1 Woodside → Sunnyside Gardens: 0Tribeca → University Village: 1 University Village → Tribeca: 0Tribeca → Washington Heights: 1 Washington Heights → Tribeca: 0Tribeca → Williamsburg: 1 Williamsburg → Tribeca: 0Tudor City → Williamsburg: 1 Williamsburg → Tudor City: 0Tudor City → Woodside: 1 Woodside → Tudor City: 0Yorkville → University Village: 1 University Village → Yorkville: 0Upper East Side → Williamsburg: 1 Williamsburg → Upper East Side: 0Upper West Side → Woodside: 1 Woodside → Upper West Side: 0Yorkville → Washington Heights: 1 Washington Heights → Yorkville: 0Washington Square Village → Yorkville: 1 Yorkville → Washington Square Village: 0East Elmhurst → Alphabet City: 2 Alphabet City → East Elmhurst: 0Alphabet City → Flatiron Building: 1 Flatiron Building → Alphabet City: 1Alphabet City → Koreatown: 1 Koreatown → Alphabet City: 1Alphabet City → Lenox Hill: 1 Lenox Hill → Alphabet City: 1NoHo Historic District → Alphabet City: 2 Alphabet City → NoHo Historic District: 0Tudor City → Alphabet City: 2 Alphabet City → Tudor City: 0Upper East Side → Alphabet City: 2 Alphabet City → Upper East Side: 0Alphabet City → Yorkville: 1 Yorkville → Alphabet City: 1Diamond District → Astoria: 2 Astoria → Diamond District: 0Battery Park City → Battery Park City: 1 Battery Park City → Battery Park City: 1Battery Park City → Flatiron Building: 1 Flatiron Building → Battery Park City: 1Kips Bay → Battery Park City: 2 Battery Park City → Kips Bay: 0Battery Park City → Koreatown: 2 Koreatown → Battery Park City: 0North Beach → Battery Park City: 2 Battery Park City → North Beach: 0Battery Park City → SoHo: 1 SoHo → Battery Park City: 1Tudor City → Battery Park City: 2 Battery Park City → Tudor City: 0Brooklyn Heights → Cobble Hill Historic District: 1 Cobble Hill Historic District → Brooklyn Heights: 1Yorkville → Brooklyn Heights: 2 Brooklyn Heights → Yorkville: 0Brooklyn Navy Yard → Tribeca: 1 Tribeca → Brooklyn Navy Yard: 1Bushwick → Bushwick: 1 Bushwick → Bushwick: 1Chelsea → Bushwick: 2 Bushwick → Chelsea: 0Diamond District → Central Park: 2 Central Park → Diamond District: 0Central Park → East Elmhurst: 1 East Elmhurst → Central Park: 1Hell's Kitchen → Central Park: 2 Central Park → Hell's Kitchen: 0Tudor City → Central Park: 2 Central Park → Tudor City: 0Central Park → Upper East Side: 2 Upper East Side → Central Park: 0Central Park → Upper West Side: 2 Upper West Side → Central Park: 0Chelsea → Chelsea: 1 Chelsea → Chelsea: 1Chelsea → Kips Bay: 2 Kips Bay → Chelsea: 0Chelsea → North Beach: 2 North Beach → Chelsea: 0Corona → Corona: 1 Corona → Corona: 1East Village → Diamond District: 2 Diamond District → East Village: 0Diamond District → Five Points: 2 Five Points → Diamond District: 0Diamond District → Lower East Side: 1 Lower East Side → Diamond District: 1Diamond District → University Village: 2 University Village → Diamond District: 0Diamond District → Williamsburg: 2 Williamsburg → Diamond District: 0Upper East Side → Downtown Brooklyn: 2 Downtown Brooklyn → Upper East Side: 0East Elmhurst → East Elmhurst: 1 East Elmhurst → East Elmhurst: 1East Elmhurst → Koreatown: 1 Koreatown → East Elmhurst: 1East Elmhurst → Murray Hill: 1 Murray Hill → East Elmhurst: 1East Elmhurst → Upper East Side: 1 Upper East Side → East Elmhurst: 1East Elmhurst → Yorkville: 2 Yorkville → East Elmhurst: 0East Harlem → East Village: 2 East Village → East Harlem: 0East Harlem → Koreatown: 1 Koreatown → East Harlem: 1East Harlem → Morningside Heights: 2 Morningside Heights → East Harlem: 0Upper West Side → East Harlem: 2 East Harlem → Upper West Side: 0East Village → Greenpoint: 1 Greenpoint → East Village: 1Hell's Kitchen → East Village: 2 East Village → Hell's Kitchen: 0East Village → Kips Bay: 2 Kips Bay → East Village: 0East Village → Koreatown: 2 Koreatown → East Village: 0East Village → Lower East Side: 2 Lower East Side → East Village: 0East Village → Rose Hill: 2 Rose Hill → East Village: 0East Village → Sunnyside Gardens: 2 Sunnyside Gardens → East Village: 0East Village → Washington Square Village: 1 Washington Square Village → East Village: 1Hell's Kitchen → Flatiron Building: 2 Flatiron Building → Hell's Kitchen: 0Flatiron Building → Kips Bay: 1 Kips Bay → Flatiron Building: 1Greenwich Village → Greenpoint: 2 Greenpoint → Greenwich Village: 0Lower East Side → Greenpoint: 2 Greenpoint → Lower East Side: 0Greenwich Village → Lower East Side: 1 Lower East Side → Greenwich Village: 1SoHo → Greenwich Village: 2 Greenwich Village → SoHo: 0Southbridge Towers → Greenwich Village: 2 Greenwich Village → Southbridge Towers: 0University Village → Greenwich Village: 2 Greenwich Village → University Village: 0Harlem → Harlem: 1 Harlem → Harlem: 1Tudor City → Harlem: 2 Harlem → Tudor City: 0Lower East Side → Hell's Kitchen: 2 Hell's Kitchen → Lower East Side: 0Rose Hill → Hell's Kitchen: 2 Hell's Kitchen → Rose Hill: 0Hell's Kitchen → Tribeca: 1 Tribeca → Hell's Kitchen: 1Rose Hill → Kips Bay: 2 Kips Bay → Rose Hill: 0Kips Bay → Tudor City: 2 Tudor City → Kips Bay: 0Kips Bay → Yorkville: 2 Yorkville → Kips Bay: 0Koreatown → Lower East Side: 2 Lower East Side → Koreatown: 0Koreatown → Midtown West: 2 Midtown West → Koreatown: 0Koreatown → Sunnyside Gardens: 2 Sunnyside Gardens → Koreatown: 0Lenox Hill → Lincoln Square: 2 Lincoln Square → Lenox Hill: 0Lenox Hill → North Beach: 1 North Beach → Lenox Hill: 1Lenox Hill → Tribeca: 2 Tribeca → Lenox Hill: 0Tudor City → Lower East Side: 2 Lower East Side → Tudor City: 0Lower East Side → Upper East Side: 1 Upper East Side → Lower East Side: 1Lower East Side → Washington Square Village: 1 Washington Square Village → Lower East Side: 1Midtown West → Upper West Side: 1 Upper West Side → Midtown West: 1Morningside Heights → Morningside Heights: 1 Morningside Heights → Morningside Heights: 1Yorkville → Morningside Heights: 2 Morningside Heights → Yorkville: 0NoHo → Tribeca: 2 Tribeca → NoHo: 0Upper East Side → NoHo: 2 NoHo → Upper East Side: 0Upper West Side → NoHo: 2 NoHo → Upper West Side: 0North Beach → North Beach: 1 North Beach → North Beach: 1North Beach → Upper East Side: 2 Upper East Side → North Beach: 0Park Slope → Tribeca: 1 Tribeca → Park Slope: 1Rose Hill → Tudor City: 1 Tudor City → Rose Hill: 1Rose Hill → Upper East Side: 1 Upper East Side → Rose Hill: 1SoHo → SoHo: 1 SoHo → SoHo: 1Southbridge Towers → Upper East Side: 1 Upper East Side → Southbridge Towers: 1Southbridge Towers → Upper West Side: 1 Upper West Side → Southbridge Towers: 1Tudor City → Washington Square Village: 1 Washington Square Village → Tudor City: 1Upper East Side → Washington Square Village: 1 Washington Square Village → Upper East Side: 1Upper West Side → Williamsburg: 1 Williamsburg → Upper West Side: 1Washington Square Village → Washington Square Village: 1 Washington Square Village → Washington Square Village: 1Alphabet City → Five Points: 2 Five Points → Alphabet City: 1Greenwich Village → Alphabet City: 2 Alphabet City → Greenwich Village: 1Washington Square Village → Alphabet City: 3 Alphabet City → Washington Square Village: 0Hell's Kitchen → Battery Park City: 3 Battery Park City → Hell's Kitchen: 0Battery Park City → Upper West Side: 2 Upper West Side → Battery Park City: 1East Elmhurst → Chelsea: 2 Chelsea → East Elmhurst: 1Chelsea → East Village: 2 East Village → Chelsea: 1Chelsea → Lenox Hill: 2 Lenox Hill → Chelsea: 1Tribeca → Chelsea: 2 Chelsea → Tribeca: 1East Elmhurst → Diamond District: 2 Diamond District → East Elmhurst: 1Diamond District → Greenpoint: 3 Greenpoint → Diamond District: 0Diamond District → Midtown West: 2 Midtown West → Diamond District: 1Diamond District → Washington Heights: 3 Washington Heights → Diamond District: 0East Elmhurst → Greenwich Village: 2 Greenwich Village → East Elmhurst: 1East Elmhurst → Tudor City: 3 Tudor City → East Elmhurst: 0East Elmhurst → Upper West Side: 2 Upper West Side → East Elmhurst: 1East Elmhurst → Williamsburg: 3 Williamsburg → East Elmhurst: 0Hell's Kitchen → East Harlem: 2 East Harlem → Hell's Kitchen: 1Lenox Hill → East Harlem: 2 East Harlem → Lenox Hill: 1Flatiron Building → East Village: 2 East Village → Flatiron Building: 1East Village → Lenox Hill: 2 Lenox Hill → East Village: 1Murray Hill → East Village: 2 East Village → Murray Hill: 1East Village → Tudor City: 3 Tudor City → East Village: 0Upper East Side → East Village: 2 East Village → Upper East Side: 1North Beach → Flatiron Building: 2 Flatiron Building → North Beach: 1Flatiron Building → SoHo: 3 SoHo → Flatiron Building: 0Greenwich Village → Upper West Side: 2 Upper West Side → Greenwich Village: 1Upper West Side → Hamilton Heights: 2 Hamilton Heights → Upper West Side: 1Kips Bay → Koreatown: 2 Koreatown → Kips Bay: 1Kips Bay → Murray Hill: 2 Murray Hill → Kips Bay: 1Kips Bay → Upper East Side: 2 Upper East Side → Kips Bay: 1Kips Bay → Washington Square Village: 3 Washington Square Village → Kips Bay: 0Lenox Hill → Koreatown: 2 Koreatown → Lenox Hill: 1Koreatown → Tribeca: 3 Tribeca → Koreatown: 0Washington Square Village → Lenox Hill: 2 Lenox Hill → Washington Square Village: 1Lower East Side → Upper West Side: 2 Upper West Side → Lower East Side: 1Yorkville → Lower East Side: 2 Lower East Side → Yorkville: 1Washington Square Village → Murray Hill: 2 Murray Hill → Washington Square Village: 1Yorkville → Murray Hill: 2 Murray Hill → Yorkville: 1Upper West Side → NoHo Historic District: 3 NoHo Historic District → Upper West Side: 0Upper East Side → SoHo: 2 SoHo → Upper East Side: 1SoHo → Upper West Side: 2 Upper West Side → SoHo: 1Sunnyside Gardens → Upper East Side: 2 Upper East Side → Sunnyside Gardens: 1Tudor City → Tribeca: 2 Tribeca → Tudor City: 1Upper East Side → Tribeca: 3 Tribeca → Upper East Side: 0Tribeca → Washington Square Village: 3 Washington Square Village → Tribeca: 0University Village → Upper West Side: 2 Upper West Side → University Village: 1Upper West Side → Washington Square Village: 3 Washington Square Village → Upper West Side: 0Alphabet City → Chelsea: 2 Chelsea → Alphabet City: 2Hell's Kitchen → Alphabet City: 3 Alphabet City → Hell's Kitchen: 1East Village → Battery Park City: 3 Battery Park City → East Village: 1Battery Park City → Greenwich Village: 4 Greenwich Village → Battery Park City: 0Lenox Hill → Battery Park City: 3 Battery Park City → Lenox Hill: 1Battery Park City → Tribeca: 4 Tribeca → Battery Park City: 0DUMBO → Diamond District: 2 Diamond District → DUMBO: 2Diamond District → NoHo Historic District: 2 NoHo Historic District → Diamond District: 2Upper East Side → East Harlem: 3 East Harlem → Upper East Side: 1East Village → Greenwich Village: 4 Greenwich Village → East Village: 0Flatiron Building → Greenwich Village: 2 Greenwich Village → Flatiron Building: 2Washington Square Village → Flatiron Building: 3 Flatiron Building → Washington Square Village: 1Flatiron Building → Yorkville: 2 Yorkville → Flatiron Building: 2Greenwich Village → Washington Square Village: 4 Washington Square Village → Greenwich Village: 0Greenwich Village → Yorkville: 2 Yorkville → Greenwich Village: 2Upper West Side → Harlem: 4 Harlem → Upper West Side: 0North Beach → Hell's Kitchen: 3 Hell's Kitchen → North Beach: 1Hell's Kitchen → SoHo: 3 SoHo → Hell's Kitchen: 1Hell's Kitchen → Washington Square Village: 4 Washington Square Village → Hell's Kitchen: 0Kips Bay → Upper West Side: 2 Upper West Side → Kips Bay: 2Koreatown → Yorkville: 3 Yorkville → Koreatown: 1Lenox Hill → Lower East Side: 2 Lower East Side → Lenox Hill: 2Lower East Side → Southbridge Towers: 3 Southbridge Towers → Lower East Side: 1Lower East Side → Tribeca: 3 Tribeca → Lower East Side: 1Tribeca → Murray Hill: 4 Murray Hill → Tribeca: 0Murray Hill → Tudor City: 2 Tudor City → Murray Hill: 2North Beach → Yorkville: 2 Yorkville → North Beach: 2Tribeca → SoHo: 3 SoHo → Tribeca: 1Southbridge Towers → Southbridge Towers: 2 Southbridge Towers → Southbridge Towers: 2Southbridge Towers → Tudor City: 3 Tudor City → Southbridge Towers: 1Tribeca → Yorkville: 4 Yorkville → Tribeca: 0Lower East Side → Alphabet City: 4 Alphabet City → Lower East Side: 1Tudor City → Chelsea: 4 Chelsea → Tudor City: 1Washington Square Village → Chelsea: 3 Chelsea → Washington Square Village: 2Diamond District → Kips Bay: 4 Kips Bay → Diamond District: 1Flatiron Building → Lenox Hill: 4 Lenox Hill → Flatiron Building: 1Flatiron Building → Upper West Side: 4 Upper West Side → Flatiron Building: 1Murray Hill → Greenwich Village: 3 Greenwich Village → Murray Hill: 2Southbridge Towers → Hell's Kitchen: 3 Hell's Kitchen → Southbridge Towers: 2Upper West Side → North Beach: 3 North Beach → Upper West Side: 2Southbridge Towers → Yorkville: 3 Yorkville → Southbridge Towers: 2Tribeca → Upper West Side: 3 Upper West Side → Tribeca: 2Tudor City → Yorkville: 4 Yorkville → Tudor City: 1Diamond District → Alphabet City: 5 Alphabet City → Diamond District: 1North Beach → Diamond District: 4 Diamond District → North Beach: 2Southbridge Towers → Diamond District: 4 Diamond District → Southbridge Towers: 2Flatiron Building → Flatiron Building: 3 Flatiron Building → Flatiron Building: 3Flatiron Building → Koreatown: 4 Koreatown → Flatiron Building: 2Greenwich Village → Lenox Hill: 3 Lenox Hill → Greenwich Village: 3Greenwich Village → Tudor City: 4 Tudor City → Greenwich Village: 2Greenwich Village → Upper East Side: 4 Upper East Side → Greenwich Village: 2Hell's Kitchen → Tudor City: 3 Tudor City → Hell's Kitchen: 3Kips Bay → Lenox Hill: 3 Lenox Hill → Kips Bay: 3Koreatown → Southbridge Towers: 4 Southbridge Towers → Koreatown: 2Tudor City → Koreatown: 4 Koreatown → Tudor City: 2Upper West Side → Morningside Heights: 4 Morningside Heights → Upper West Side: 2Murray Hill → Murray Hill: 3 Murray Hill → Murray Hill: 3Upper West Side → Murray Hill: 4 Murray Hill → Upper West Side: 2Chelsea → Flatiron Building: 5 Flatiron Building → Chelsea: 2Chelsea → Yorkville: 6 Yorkville → Chelsea: 1Upper East Side → Flatiron Building: 4 Flatiron Building → Upper East Side: 3Greenwich Village → Tribeca: 5 Tribeca → Greenwich Village: 2Lenox Hill → Murray Hill: 4 Murray Hill → Lenox Hill: 3Battery Park City → Upper East Side: 4 Upper East Side → Battery Park City: 4Chelsea → Upper East Side: 5 Upper East Side → Chelsea: 3SoHo → Diamond District: 5 Diamond District → SoHo: 3Tribeca → Diamond District: 6 Diamond District → Tribeca: 2Greenwich Village → Greenwich Village: 4 Greenwich Village → Greenwich Village: 4Koreatown → Greenwich Village: 5 Greenwich Village → Koreatown: 3Koreatown → Murray Hill: 5 Murray Hill → Koreatown: 3Murray Hill → Upper East Side: 8 Upper East Side → Murray Hill: 0Tribeca → Tribeca: 4 Tribeca → Tribeca: 4Greenwich Village → Diamond District: 7 Diamond District → Greenwich Village: 2Lenox Hill → Hell's Kitchen: 6 Hell's Kitchen → Lenox Hill: 3Yorkville → Hell's Kitchen: 6 Hell's Kitchen → Yorkville: 3Battery Park City → Diamond District: 5 Diamond District → Battery Park City: 5Koreatown → Chelsea: 6 Chelsea → Koreatown: 4Greenwich Village → Hell's Kitchen: 8 Hell's Kitchen → Greenwich Village: 2Koreatown → Koreatown: 5 Koreatown → Koreatown: 5Yorkville → Yorkville: 5 Yorkville → Yorkville: 5Murray Hill → Diamond District: 6 Diamond District → Murray Hill: 5Rose Hill → Diamond District: 7 Diamond District → Rose Hill: 4Diamond District → Washington Square Village: 9 Washington Square Village → Diamond District: 3Hell's Kitchen → Hell's Kitchen: 6 Hell's Kitchen → Hell's Kitchen: 6Tudor City → Lenox Hill: 7 Lenox Hill → Tudor City: 5Chelsea → Upper West Side: 8 Upper West Side → Chelsea: 5Upper West Side → Koreatown: 7 Koreatown → Upper West Side: 6Tudor City → Upper West Side: 8 Upper West Side → Tudor City: 6Chelsea → Greenwich Village: 8 Greenwich Village → Chelsea: 7Koreatown → Upper East Side: 9 Upper East Side → Koreatown: 6Lenox Hill → Yorkville: 9 Yorkville → Lenox Hill: 7Tudor City → Tudor City: 8 Tudor City → Tudor City: 8Flatiron Building → Diamond District: 9 Diamond District → Flatiron Building: 8Diamond District → Yorkville: 12 Yorkville → Diamond District: 5Tudor City → Upper East Side: 9 Upper East Side → Tudor City: 8Yorkville → Upper West Side: 10 Upper West Side → Yorkville: 7Tudor City → Diamond District: 10 Diamond District → Tudor City: 8Koreatown → Hell's Kitchen: 12 Hell's Kitchen → Koreatown: 6Hell's Kitchen → Upper East Side: 9 Upper East Side → Hell's Kitchen: 9Lenox Hill → Upper West Side: 12 Upper West Side → Lenox Hill: 6Hell's Kitchen → Chelsea: 15 Chelsea → Hell's Kitchen: 4Lenox Hill → Lenox Hill: 10 Lenox Hill → Lenox Hill: 10Upper East Side → Yorkville: 14 Yorkville → Upper East Side: 6Diamond District → Lenox Hill: 14 Lenox Hill → Diamond District: 7Chelsea → Diamond District: 14 Diamond District → Chelsea: 9Hell's Kitchen → Upper West Side: 16 Upper West Side → Hell's Kitchen: 10Diamond District → Hell's Kitchen: 21 Hell's Kitchen → Diamond District: 10Koreatown → Diamond District: 20 Diamond District → Koreatown: 11Lenox Hill → Upper East Side: 20 Upper East Side → Lenox Hill: 16Upper West Side → Upper East Side: 21 Upper East Side → Upper West Side: 17Diamond District → Upper West Side: 23 Upper West Side → Diamond District: 19Upper East Side → Diamond District: 23 Diamond District → Upper East Side: 21Diamond District → Diamond District: 25 Diamond District → Diamond District: 25Upper East Side → Upper East Side: 28 Upper East Side → Upper East Side: 28Upper West Side → Upper West Side: 40 Upper West Side → Upper West Side: 40

Chord Diagram

There are many flavors of circos diagram depending on the application. To show the flow and magnitude of of the taxi ride data, chord diagam is the most appropriate. The each chord displays the flow or relatinship(e.g., correlation) between different entities, and the metric of interest can be visualized by the width of each chord. The input for the chord diagram is a standard matrix called the 'Adjacency matrix' [1], in which a nxn matrix quantifies the flow from X to Y. In this matrix, the row names and columns names are identical and in the same order. For the taxi data, the rows(i) and columns(j) represent the pick up location and dropoff location, respectively. The matrix value(i,j) is the number of people going from location i to location j, and it determines the thickness of the corresponding chord. To retrieve neighbourhood names from the raw data, I used the Python packages geopy and pygeocoder to extract the neighbourhood information using GPS coordinates for the pickup and dropoff locations.The codes are available here, and the outputs are the matrix json file, and a .csv file with row names and html color codes.

Step I. Donut Chart

The Donut Chart (Fig.1) serves as the backbone of the chord diagram. To make the donut, define the layout with d3.layout.chord() and d3.svg.arc() . A mouseover function is added to show how many people are leaving that neighborhood. See complete donut codes here

donut
Fig.1. Donut chart showing the arcs corresponding to the groups. The size of each arc is determined by the sum of the values of that group ( summing along the columns for row i).

Step II: Adding chords and text labels

After getting the donut chart, chords and text labels (Fig.2) can be added, with the following additional code:

//add text label of the groups
group.append("svg:text")
.each(function(d) { d.angle = ((d.startAngle + d.endAngle) / 2);})
.attr("dy", ".25em")
.attr("class", "titles")
.attr("text-anchor", function(d) { return d.angle > Math.PI ? "end" : null; })
.attr("transform", function(d,i) {
var c = arc.centroid(d);
return "rotate(" + (d.angle * 180 / Math.PI - 90) + ")"
+ "translate(" + (innerRadius + 15) + ")" //how close the labels are to the outer arc
+ (d.angle > Math.PI ? "rotate(180)" : "")
})
.text(function(d,i) { return cities[i].name; });
// Add the chords.
var chord = svg.selectAll(".chord")
.data(layout.chords)
.enter().append("path")
.attr("class", "chord")
.style("fill", function(d) { return cities[d.source.index].color; })
.attr("d", path);
view raw chord.js hosted with ❤ by GitHub
full chord
Fig.2. Chord diagram (no tooltip and no fading with mouseover).

Step III: Mouseover tool tip and fading

Finally, interactive features are what makes D3 graphics so appealing. To add tool tips showing the number of people coming in and leaving the neighbourhood, a text function is appended to the variable chord. And to apply fading affects with mouseover, go back to the variable "group" to add the functionality. The codes shown below are added to the ones above, and the complete .js code (for the first interactive graph) can be found here.

// Add a group per neighborhood.
var group = svg.selectAll(".group")
.data(layout.groups)
.enter().append("g")
.attr("class", "group")
.on("mouseover", mouseover);;
// tool tip info for the chords
chord.append("title").text(function(d) {
return cities[d.source.index].name
+ " → " + cities[d.target.index].name
+ ": " + (d.source.value)
+ "\n" + cities[d.target.index].name
+ " → " + cities[d.source.index].name
+ ": " + (d.target.value);
});
//mouse over function
function mouseover(d, i) {
chord.classed("fade", function(p) {
return p.source.index != i
&& p.target.index != i;
});
}
});
});
view raw chord.js hosted with ❤ by GitHub

To embed the D3 javascript into the html, simply call the .js file with the script src ="" function. In practice, it's common to use div to define the area for D3 effects. For example, in this html web page, I inserted the D3 script in between a div element with id called "chart" . The id is called in the chord.js file to select that element by specifying d3.select("div#chart").append("svg").

I found that the fastest way to hack D3 is by looking at well-annotated codes (I love the ones written by Nadieh Bremer ) AND using JSFiddle interactive tool to test out different javascript and see its effect.

REFERENCE

[1] https://medium.com/@Marianattestad/a-treatise-on-making-circos-plots-from-genomic-data-7ff496849e0

[2] How to create a Flow diagram with a circular Twist, Visual Cinnamon, https://www.visualcinnamon.com/2015/08/stretched-chord.html

[3] Andrew's Chord Example http://bl.ocks.org/AndrewRP/7468330