Skip to content

Instantly share code, notes, and snippets.

@camille-s
Created February 22, 2015 19:39
Show Gist options
  • Save camille-s/4e32e9be47334ff1409a to your computer and use it in GitHub Desktop.
Save camille-s/4e32e9be47334ff1409a to your computer and use it in GitHub Desktop.
ytdn
<!doctype HTML>
<meta charset = 'utf-8'>
<html>
<head>
<link rel='stylesheet' href='//cdnjs.cloudflare.com/ajax/libs/nvd3/1.1.15-beta/nv.d3.min.css'>
<script src='//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js' type='text/javascript'></script>
<script src='//d3js.org/d3.v3.min.js' type='text/javascript'></script>
<script src='//cdnjs.cloudflare.com/ajax/libs/nvd3/1.1.15-beta/nv.d3.min.js' type='text/javascript'></script>
<script src='//nvd3.org/assets/lib/fisheye.js' type='text/javascript'></script>
<style>
.rChart {
display: block;
margin-left: auto;
margin-right: auto;
width: 800px;
height: 400px;
}
</style>
</head>
<body >
<div id = 'chartf160c031c6' class = 'rChart nvd3'></div>
<script type='text/javascript'>
$(document).ready(function(){
drawchartf160c031c6()
});
function drawchartf160c031c6(){
var opts = {
"dom": "chartf160c031c6",
"width": 800,
"height": 400,
"x": "date",
"y": "num",
"id": "chartf160c031c6"
},
data = [
{
"num": 1,
"date": 15340,
"city": "Atlanta",
"state": "GA",
"age": 17
},
{
"num": 3,
"date": 15348,
"city": "Houston",
"state": "TX",
"age": 18
},
{
"num": 5,
"date": 15349,
"city": "Miami Metro,",
"state": "FL",
"age": 23
},
{
"num": 6,
"date": 15351,
"city": "New Orleans",
"state": "LA",
"age": 21
},
{
"num": 8,
"date": 15352,
"city": "St Johns",
"state": "FL",
"age": 59
},
{
"num": 9,
"date": 15353,
"city": "Jacksonville",
"state": "FL",
"age": 17
},
{
"num": 10,
"date": 15356,
"city": "Little Rock",
"state": "AR",
"age": 31
},
{
"num": 12,
"date": 15363,
"city": "Baltimore",
"state": "MD",
"age": 20
},
{
"num": 13,
"date": 15365,
"city": "New York",
"state": "NY",
"age": 22
},
{
"num": 14,
"date": 15367,
"city": "Rockford",
"state": "IL",
"age": 29
},
{
"num": 15,
"date": 15368,
"city": "New York",
"state": "NY",
"age": 17
},
{
"num": 16,
"date": 15370,
"city": "Headland",
"state": "AL",
"age": 33
},
{
"num": 17,
"date": 15371,
"city": "Chicago",
"state": "IL",
"age": 15
},
{
"num": 18,
"date": 15373,
"city": "Mobile",
"state": "AL",
"age": 24
},
{
"num": 20,
"date": 15375,
"city": "Rockingham",
"state": "NC",
"age": 36
},
{
"num": 21,
"date": 15376,
"city": "Sacramento",
"state": "CA",
"age": 47
},
{
"num": 22,
"date": 15378,
"city": "Dallas",
"state": "TX",
"age": 27
},
{
"num": 23,
"date": 15380,
"city": "Chicago",
"state": "IL",
"age": 47
},
{
"num": 26,
"date": 15382,
"city": "Jacksonville",
"state": "FL",
"age": 24
},
{
"num": 27,
"date": 15383,
"city": "Dallas",
"state": "TX",
"age": 26
},
{
"num": 29,
"date": 15384,
"city": "New York",
"state": "NY",
"age": 52
},
{
"num": 30,
"date": 15391,
"city": "Los Angeles,",
"state": "CA",
"age": 22
},
{
"num": 31,
"date": 15396,
"city": "Sanford",
"state": "FL",
"age": 17
},
{
"num": 32,
"date": 15398,
"city": "Kershaw",
"state": "SC",
"age": 26
},
{
"num": 33,
"date": 15399,
"city": "Galveston",
"state": "TX",
"age": 34
},
{
"num": 34,
"date": 15400,
"city": "Atlanta Metro",
"state": "GA",
"age": 24
},
{
"num": 39,
"date": 15402,
"city": "West Bend",
"state": "WI",
"age": 20
},
{
"num": 40,
"date": 15403,
"city": "Baltimore",
"state": "MD",
"age": 13
},
{
"num": 41,
"date": 15404,
"city": "Gainesville",
"state": "FL",
"age": 29
},
{
"num": 43,
"date": 15405,
"city": "Bush Creek",
"state": "PA",
"age": 45
},
{
"num": 44,
"date": 15406,
"city": "New Orleans",
"state": "LA",
"age": 20
},
{
"num": 46,
"date": 15409,
"city": "Cleveland",
"state": "OH",
"age": 20
},
{
"num": 50,
"date": 15411,
"city": "Aurora",
"state": "IL",
"age": 37
},
{
"num": 51,
"date": 15412,
"city": "Cleveland",
"state": "OH",
"age": 23
},
{
"num": 52,
"date": 15413,
"city": "Del City",
"state": "OK",
"age": 18
},
{
"num": 53,
"date": 15414,
"city": "New York",
"state": "NY",
"age": 30
},
{
"num": 54,
"date": 15420,
"city": "Cleveland",
"state": "OH",
"age": 42
},
{
"num": 55,
"date": 15422,
"city": "Detroit",
"state": "MI",
"age": 18
},
{
"num": 57,
"date": 15423,
"city": "Atlanta",
"state": "GA",
"age": 18
},
{
"num": 59,
"date": 15424,
"city": "Chicago",
"state": "IL",
"age": 52
},
{
"num": 61,
"date": 15426,
"city": "Atlanta",
"state": "GA",
"age": 18
},
{
"num": 64,
"date": 15427,
"city": "Washington",
"state": "DC",
"age": 19
},
{
"num": 65,
"date": 15428,
"city": "St Louis",
"state": "MO",
"age": 34
},
{
"num": 66,
"date": 15429,
"city": "Chicago",
"state": "IL",
"age": 25
},
{
"num": 67,
"date": 15430,
"city": "Baltimore",
"state": "MD",
"age": 29
},
{
"num": 69,
"date": 15435,
"city": "Austin",
"state": "TX",
"age": 35
},
{
"num": 71,
"date": 15436,
"city": "Stockton",
"state": "CA",
"age": 32
},
{
"num": 75,
"date": 15438,
"city": "Washington",
"state": "MD",
"age": 26
},
{
"num": 76,
"date": 15440,
"city": "Fayetteville",
"state": "NC",
"age": 26
},
{
"num": 79,
"date": 15442,
"city": "New York",
"state": "NY",
"age": 27
},
{
"num": 82,
"date": 15443,
"city": "Memphis",
"state": "TN",
"age": 38
},
{
"num": 84,
"date": 15444,
"city": "Chicago",
"state": "IL",
"age": 22
},
{
"num": 85,
"date": 15446,
"city": "Birmingham",
"state": "AL",
"age": 28
},
{
"num": 87,
"date": 15450,
"city": "Gretna",
"state": "LA",
"age": 21
},
{
"num": 89,
"date": 15451,
"city": "Chicago",
"state": "IL",
"age": 20
},
{
"num": 91,
"date": 15452,
"city": "Philadelphia",
"state": "PA",
"age": 31
},
{
"num": 92,
"date": 15458,
"city": "Birmingham",
"state": "AL",
"age": 13
},
{
"num": 93,
"date": 15459,
"city": "Allentown",
"state": "PA",
"age": 23
},
{
"num": 96,
"date": 15460,
"city": "Chicago",
"state": "IL",
"age": 27
},
{
"num": 97,
"date": 15461,
"city": "Indianapolis",
"state": "IN",
"age": 28
},
{
"num": 98,
"date": 15462,
"city": "Pearl",
"state": "MS",
"age": 30
},
{
"num": 99,
"date": 15465,
"city": "Fayetteville",
"state": "NC",
"age": 27
},
{
"num": 100,
"date": 15466,
"city": "Oakland",
"state": "CA",
"age": 17
},
{
"num": 101,
"date": 15468,
"city": "Memphis",
"state": "TN",
"age": 38
},
{
"num": 103,
"date": 15469,
"city": "Buckingham",
"state": "FL",
"age": 31
},
{
"num": 105,
"date": 15470,
"city": "Baldwin",
"state": "LA",
"age": 34
},
{
"num": 109,
"date": 15474,
"city": "Atlanta",
"state": "GA",
"age": 28
},
{
"num": 110,
"date": 15475,
"city": "LaGrange",
"state": "NY",
"age": 22
},
{
"num": 112,
"date": 15477,
"city": "Birmingham",
"state": "AL",
"age": 38
},
{
"num": 114,
"date": 15478,
"city": "Houston",
"state": "TX",
"age": 24
},
{
"num": 116,
"date": 15479,
"city": "Baltimore",
"state": "MD",
"age": 31
},
{
"num": 117,
"date": 15482,
"city": "Columbus",
"state": "OH",
"age": 28
},
{
"num": 119,
"date": 15484,
"city": "Houston",
"state": "TX",
"age": 51
},
{
"num": 120,
"date": 15485,
"city": "Birmingham",
"state": "AL",
"age": 27
},
{
"num": 121,
"date": 15486,
"city": "Galveston",
"state": "TX",
"age": 44
},
{
"num": 123,
"date": 15487,
"city": "Dallas",
"state": "TX",
"age": 30
},
{
"num": 124,
"date": 15488,
"city": "Vallejo",
"state": "CA",
"age": 42
},
{
"num": 125,
"date": 15489,
"city": "Dallas",
"state": "TX",
"age": 44
},
{
"num": 126,
"date": 15491,
"city": "Jacksonville",
"state": "FL",
"age": 32
},
{
"num": 128,
"date": 15492,
"city": "Miami",
"state": "FL",
"age": 29
},
{
"num": 130,
"date": 15493,
"city": "Dallas",
"state": "TX",
"age": 21
},
{
"num": 131,
"date": 15496,
"city": "South San",
"state": "CA",
"age": 15
},
{
"num": 132,
"date": 15503,
"city": "Memphis",
"state": "TN",
"age": 19
},
{
"num": 133,
"date": 15504,
"city": "Baltimore",
"state": "MD",
"age": 17
},
{
"num": 135,
"date": 15505,
"city": "New York",
"state": "NY",
"age": 23
},
{
"num": 136,
"date": 15507,
"city": "Atlanta Metro",
"state": "GA",
"age": 26
},
{
"num": 137,
"date": 15511,
"city": "Washington",
"state": "DC",
"age": 44
},
{
"num": 138,
"date": 15512,
"city": "Atlanta Metro",
"state": "GA",
"age": null
},
{
"num": 140,
"date": 15513,
"city": "Houston",
"state": "TX",
"age": null
},
{
"num": 142,
"date": 15514,
"city": "Chicago",
"state": "IL",
"age": 56
},
{
"num": 144,
"date": 15515,
"city": "Dallas",
"state": "TX",
"age": 18
},
{
"num": 145,
"date": 15516,
"city": "Johnstown",
"state": "PA",
"age": 27
},
{
"num": 146,
"date": 15517,
"city": "Cincinnati",
"state": "OH",
"age": 35
},
{
"num": 148,
"date": 15518,
"city": "Atlanta",
"state": "GA",
"age": 38
},
{
"num": 152,
"date": 15519,
"city": "Antioch",
"state": "CA",
"age": 35
},
{
"num": 157,
"date": 15521,
"city": "Seattle Metro",
"state": "WA",
"age": 25
},
{
"num": 158,
"date": 15522,
"city": "Baltimore",
"state": "MD",
"age": 38
},
{
"num": 160,
"date": 15523,
"city": "Charlotte",
"state": "NC",
"age": 28
},
{
"num": 161,
"date": 15524,
"city": "Anderson",
"state": "SC",
"age": 2
},
{
"num": 163,
"date": 15525,
"city": "New York",
"state": "NY",
"age": 46
},
{
"num": 164,
"date": 15526,
"city": "Columbia",
"state": "SC",
"age": 29
},
{
"num": 165,
"date": 15529,
"city": "Chicago",
"state": "IL",
"age": 19
},
{
"num": 167,
"date": 15530,
"city": "Detroit",
"state": "MI",
"age": 23
},
{
"num": 168,
"date": 15531,
"city": "St. Louis",
"state": "MO",
"age": 23
},
{
"num": 170,
"date": 15532,
"city": "San",
"state": "CA",
"age": 27
},
{
"num": 171,
"date": 15533,
"city": "Reisterstown",
"state": "MD",
"age": 48
},
{
"num": 172,
"date": 15534,
"city": "Atlanta",
"state": "GA",
"age": 39
},
{
"num": 176,
"date": 15535,
"city": "Columbus",
"state": "OH",
"age": 51
},
{
"num": 177,
"date": 15536,
"city": "Miami",
"state": "FL",
"age": 36
},
{
"num": 178,
"date": 15538,
"city": "Columbus",
"state": "OH",
"age": 21
},
{
"num": 179,
"date": 15541,
"city": "Tulsa",
"state": "OK",
"age": 26
},
{
"num": 180,
"date": 15542,
"city": "Atlanta",
"state": "GA",
"age": 59
},
{
"num": 181,
"date": 15543,
"city": "Los Angeles",
"state": "CA",
"age": 35
},
{
"num": 183,
"date": 15544,
"city": "Boston",
"state": "MA",
"age": 23
},
{
"num": 184,
"date": 15545,
"city": "Dallas",
"state": "TX",
"age": 31
},
{
"num": 185,
"date": 15546,
"city": "Clearwater",
"state": "FL",
"age": 19
},
{
"num": 186,
"date": 15547,
"city": "Akron",
"state": "OH",
"age": 35
},
{
"num": 187,
"date": 15549,
"city": "Jonesboro",
"state": "AR",
"age": 21
},
{
"num": 188,
"date": 15551,
"city": "Tupelo",
"state": "MS",
"age": 22
},
{
"num": 189,
"date": 15559,
"city": "Houston",
"state": "TX",
"age": 33
},
{
"num": 192,
"date": 15560,
"city": "Chicago",
"state": "IL",
"age": 19
},
{
"num": 195,
"date": 15561,
"city": "Baltimore",
"state": "MD",
"age": 32
},
{
"num": 201,
"date": 15563,
"city": "Chicago",
"state": "IL",
"age": 26
},
{
"num": 205,
"date": 15564,
"city": "Atlanta Metro",
"state": "GA",
"age": 52
},
{
"num": 209,
"date": 15565,
"city": "Decatur",
"state": "AL",
"age": 36
},
{
"num": 210,
"date": 15568,
"city": "Iowa City",
"state": "IA",
"age": 24
},
{
"num": 211,
"date": 15569,
"city": "Cincinnati",
"state": "OH",
"age": 51
},
{
"num": 213,
"date": 15570,
"city": "Atlanta",
"state": "GA",
"age": 26
},
{
"num": 216,
"date": 15572,
"city": "Chattanooga",
"state": "TN",
"age": 32
},
{
"num": 218,
"date": 15573,
"city": "Boston",
"state": "MA",
"age": 26
},
{
"num": 220,
"date": 15574,
"city": "Birmingham",
"state": "AL",
"age": 21
},
{
"num": 221,
"date": 15576,
"city": "Goldsboro",
"state": "NC",
"age": null
},
{
"num": 223,
"date": 15578,
"city": "Baton Rouge",
"state": "LA",
"age": 32
},
{
"num": 226,
"date": 15580,
"city": "Los Angeles",
"state": "CA",
"age": 22
},
{
"num": 227,
"date": 15581,
"city": "St. Louis",
"state": "MO",
"age": 18
},
{
"num": 228,
"date": 15582,
"city": "Seminole",
"state": "OK",
"age": 24
},
{
"num": 229,
"date": 15583,
"city": "Minneapolis",
"state": "MN",
"age": 19
},
{
"num": 231,
"date": 15585,
"city": "Vallejo",
"state": "CA",
"age": 23
},
{
"num": 232,
"date": 15586,
"city": "Jacksonville",
"state": "FL",
"age": 27
},
{
"num": 233,
"date": 15588,
"city": "Orlando",
"state": "FL",
"age": 17
},
{
"num": 234,
"date": 15590,
"city": "Cochran",
"state": "GA",
"age": 31
},
{
"num": 237,
"date": 15591,
"city": "Alexander",
"state": "AR",
"age": 30
},
{
"num": 238,
"date": 15594,
"city": "Atlanta Metro",
"state": "GA",
"age": 27
},
{
"num": 239,
"date": 15596,
"city": "Houston",
"state": "TX",
"age": 26
},
{
"num": 240,
"date": 15597,
"city": "Chicago",
"state": "IL",
"age": 22
},
{
"num": 241,
"date": 15599,
"city": "Omaha",
"state": "NE",
"age": 29
},
{
"num": 242,
"date": 15603,
"city": "High Point",
"state": "NC",
"age": 60
},
{
"num": 244,
"date": 15604,
"city": "Baltimore",
"state": "MD",
"age": 46
},
{
"num": 246,
"date": 15606,
"city": "Seattle",
"state": "WA",
"age": 77
},
{
"num": 247,
"date": 15607,
"city": "Memphis",
"state": "TN",
"age": 15
},
{
"num": 248,
"date": 15610,
"city": "Lauderhill",
"state": "FL",
"age": 73
},
{
"num": 249,
"date": 15611,
"city": "Henderson",
"state": "LA",
"age": 32
},
{
"num": 250,
"date": 15615,
"city": "Miami",
"state": "FL",
"age": 26
},
{
"num": 251,
"date": 15617,
"city": "Houston",
"state": "TX",
"age": 45
},
{
"num": 252,
"date": 15618,
"city": "Hayward",
"state": "CA",
"age": 21
},
{
"num": 254,
"date": 15621,
"city": "Washington",
"state": "DC",
"age": 22
},
{
"num": 255,
"date": 15623,
"city": "Morgan City",
"state": "LA",
"age": 44
},
{
"num": 256,
"date": 15624,
"city": "Houston",
"state": "TX",
"age": 37
},
{
"num": 259,
"date": 15626,
"city": "Cincinnati (Mt",
"state": "OH",
"age": 26
},
{
"num": 261,
"date": 15627,
"city": "Columbus",
"state": "GA",
"age": 26
},
{
"num": 262,
"date": 15631,
"city": "Louisville",
"state": "KY",
"age": 31
},
{
"num": 263,
"date": 15633,
"city": "Birmingham",
"state": "AL",
"age": 22
},
{
"num": 264,
"date": 15636,
"city": "Minneapolis/S",
"state": "MN",
"age": 41
},
{
"num": 265,
"date": 15637,
"city": "New York",
"state": "NY",
"age": 18
},
{
"num": 267,
"date": 15638,
"city": "Keller",
"state": "TX",
"age": 42
},
{
"num": 268,
"date": 15640,
"city": "New York",
"state": "NY",
"age": 20
},
{
"num": 269,
"date": 15645,
"city": "Houston",
"state": "TX",
"age": 22
},
{
"num": 271,
"date": 15649,
"city": "Fremont",
"state": "CA",
"age": 37
},
{
"num": 272,
"date": 15650,
"city": "St.",
"state": "FL",
"age": 36
},
{
"num": 273,
"date": 15652,
"city": "Chicago",
"state": "IL",
"age": 15
},
{
"num": 275,
"date": 15653,
"city": "Ward",
"state": "AR",
"age": 21
},
{
"num": 276,
"date": 15654,
"city": "Philadelphia",
"state": "PA",
"age": 19
},
{
"num": 277,
"date": 15655,
"city": "Detroit",
"state": "MI",
"age": 64
},
{
"num": 278,
"date": 15656,
"city": "Philadelphia",
"state": "PA",
"age": 35
},
{
"num": 279,
"date": 15658,
"city": "Chicago",
"state": "IL",
"age": 20
},
{
"num": 280,
"date": 15662,
"city": "Waterloo",
"state": "IA",
"age": 22
},
{
"num": 281,
"date": 15664,
"city": "Cincinnati",
"state": "OH",
"age": 19
},
{
"num": 282,
"date": 15666,
"city": "Detroit",
"state": "MI",
"age": 25
},
{
"num": 283,
"date": 15667,
"city": "Jacksonville",
"state": "FL",
"age": 17
},
{
"num": 284,
"date": 15669,
"city": "Atlanta Metro",
"state": "GA",
"age": 38
},
{
"num": 287,
"date": 15673,
"city": "Cleveland",
"state": "OH",
"age": 43
},
{
"num": 289,
"date": 15674,
"city": "Fayetteville",
"state": "NC",
"age": 25
},
{
"num": 290,
"date": 15676,
"city": "Breaux",
"state": "LA",
"age": 16
},
{
"num": 291,
"date": 15677,
"city": "Childersburg",
"state": "AL",
"age": 36
},
{
"num": 292,
"date": 15678,
"city": "Atlanta Metro",
"state": "GA",
"age": 20
},
{
"num": 293,
"date": 15680,
"city": "Atlanta Metro",
"state": "GA",
"age": 19
},
{
"num": 296,
"date": 15682,
"city": "San",
"state": "CA",
"age": 38
},
{
"num": 297,
"date": 15686,
"city": "Chester",
"state": "PA",
"age": 30
},
{
"num": 299,
"date": 15687,
"city": "Chicago",
"state": "IL",
"age": 38
},
{
"num": 300,
"date": 15688,
"city": "Dallas",
"state": "TX",
"age": 30
},
{
"num": 301,
"date": 15689,
"city": "Chicago",
"state": "IL",
"age": 23
},
{
"num": 303,
"date": 15691,
"city": "Atlantic City",
"state": "NJ",
"age": 18
},
{
"num": 305,
"date": 15695,
"city": "Macon",
"state": "GA",
"age": 49
},
{
"num": 306,
"date": 15696,
"city": "St Louis",
"state": "MO",
"age": 39
},
{
"num": 307,
"date": 15697,
"city": "Tahoka",
"state": "TX",
"age": 35
},
{
"num": 308,
"date": 15698,
"city": "Houston",
"state": "TX",
"age": 21
},
{
"num": 309,
"date": 15699,
"city": "Richland",
"state": "WA",
"age": 29
},
{
"num": 310,
"date": 15701,
"city": "Memphis",
"state": "TN",
"age": 32
},
{
"num": 311,
"date": 15702,
"city": "Philadelphia",
"state": "PA",
"age": 39
},
{
"num": 313,
"date": 15704,
"city": "Hearne",
"state": "TX",
"age": 28
}
]
if(!(opts.type==="pieChart" || opts.type==="sparklinePlus" || opts.type==="bulletChart")) {
var data = d3.nest()
.key(function(d){
//return opts.group === undefined ? 'main' : d[opts.group]
//instead of main would think a better default is opts.x
return opts.group === undefined ? opts.y : d[opts.group];
})
.entries(data);
}
if (opts.disabled != undefined){
data.map(function(d, i){
d.disabled = opts.disabled[i]
})
}
nv.addGraph(function() {
var chart = nv.models[opts.type]()
.width(opts.width)
.height(opts.height)
if (opts.type != "bulletChart"){
chart
.x(function(d) { return d[opts.x] })
.y(function(d) { return d[opts.y] })
}
d3.select("#" + opts.id)
.append('svg')
.datum(data)
.transition().duration(500)
.call(chart);
nv.utils.windowResize(chart.update);
return chart;
});
};
</script>
<script></script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment