Skip to content

Instantly share code, notes, and snippets.

@poezn
Forked from anonymous/_.md
Created August 28, 2012 07:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save poezn/3495727 to your computer and use it in GitHub Desktop.
Save poezn/3495727 to your computer and use it in GitHub Desktop.
just another inlet to tributary
{"editor_editor":{"coffee":false,"vim":false,"emacs":false,"width":752,"height":838,"hide":false},"editor_json0":{"vim":false,"emacs":false,"width":735,"height":376,"hide":true},"editor_json1":{"vim":false,"emacs":false,"width":1910,"height":120,"hide":false},"endpoint":"tributary","editor_json2":{"vim":false,"emacs":false,"width":1809,"height":114,"hide":false}}
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
d3.selection.prototype.moveToFront = function() {
return this.each(function() {
this.parentNode.appendChild(this);
});
};
var defs = g.append('defs');
var mask = defs.append('mask')
.attr('id', 'clipper');
mask
.append('rect')
.attr('height', $('body').height())
.attr('width', $('body').width())
.style('fill', "#4D4D4D");
mask
.attr('cy', 100)
.attr('r', 100)
.attr('fill', 'white')
.attr('maskContentUnits', "objectBoundingBox")
var json0 = tributary["geojson0"];
var json1 = tributary["geojson1"];
var texts = tributary["text_data"];
var current;
var tooltip, shapes;
var categories = _.uniq(_.map(json0.features, function(d) { return d.properties.category; }));
var colorScale = d3.scale.ordinal().range(['#5b88a5', '#87af20', '#ffc240', "#DD8000", "#E06A87"]);
var color = function(d, i) {
return colorScale(d.properties.category);
}
var xy = d3.geo.albers()
.scale(1200)
.translate([437, 355]);
var path = d3.geo.path()
.projection(xy);
var categoryLabels = {
'none': 'Unclaimed',
'other_country': 'Other Countries',
'disputed': 'Disputed Areas',
'territory': 'US Territories',
'state': 'US State'
};
// =============
// FUNCTIONS
var showTooltip = function(d, i) {
var text = d.properties.label;
if (d.properties.country) {
text += ' (' + d.properties.country + ')';
}
// show tooltip
tooltip.text(text)
.style('visibility', null);
d3.select('#cover')
.style('visibility', null)
.style('mask', 'url(#clipper)')
.moveToFront();
d3.select(this)
.style('fill', "#EBDFCD");
moveTooltip(d, i);
};
var moveTooltip = function(d, i) {
// move tooltip
var m = d3.svg.mouse(this);
tooltip.attr('transform', 'translate(' + m + ')');
};
var drawMap = function(js) {
if (current == json0) {
current = json1;
} else {
current = json0;
}
var sh = g.selectAll('path.shapes')
.data(js, function(d) { return d.properties.id } );
sh.enter()
.append('path')
.attr('class', 'shapes')
.attr('d', path)
.style('fill', color)
.style('stroke', "#FFFFFF")
.on('mouseover', showTooltip)
.on('mousemove', moveTooltip)
.on('mouseout', function(d, i) {
d3.select('#cover')
.style('visibility', 'hidden');
tooltip.style('visibility', 'hidden');
d3.select(this).style('fill', color)
})
.on('click', function() {
drawMap(current.features);
});
sh.exit()
.remove();
sh.transition()
.delay(1000)
.duration(1000)
.attr('d', path);
};
g.append('rect')
.attr('id', 'cover')
.attr('width', $('body').width())
.attr('height', $('body').height())
.attr("pointer-events", "none")
.style('visibility', 'hidden')
.moveToFront();
// ========= TIMELINE
var dates = _.map(texts, function(d) {
var parts = d.date.match(/(\d+)/g);
// new Date(year, month [, date [, hours[, minutes[, seconds[, ms]]]]])
return new Date(parts[0], parts[1]-1, parts[2]); // months are 0-based
});
var xscale = d3.time.scale()
.domain([d3.min(dates), d3.max(dates)])
.range([25, 800]);
var timeline = g.selectAll('circle')
.data(dates)
.enter().append('circle')
.attr('cx', xscale )
.attr('cy', 668)
.attr('r', 5)
.style('opacity', .1);
var axis = d3.svg.axis()
.scale(xscale)
.ticks(d3.time.years, 10);
g.append("g")
.attr("transform", "translate(" + [0,687] + ")")
.call(axis);
// ========= LEGEND
var yscale = d3.scale.ordinal()
.domain(d3.range(0, categories.length))
.rangeBands([87, 277]);
var legend = g.selectAll('g.legenditem')
.data(categories)
.enter().append('g')
.attr('class', 'legenditem')
.attr('transform', function(d, i) {
return 'translate(' + [930, yscale(i)] + ')';
})
.attr('width', 300)
.attr('height', yscale.rangeBand());
legend.append('text')
.text(function(d, i) {
return categoryLabels[d];
})
.attr('transform', 'translate(' + [26, 15] + ')')
legend.append('rect')
.attr('width', 20)
.attr('height', 20)
.style('fill', colorScale)
drawMap(json0.features);
tooltip = g.append('text')
.attr("pointer-events", "none");
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file has been truncated, but you can view the full file.
[{"date": "1789-03-04", "id": "1789-03", "paragraphs": ["The United States Constitution came into effect, forming the new nation. Note that the states ratified at different times, but to simplify the map, the final result is shown here.", "The United States achieved independence from the Kingdom of Great Britain with the Treaty of Paris on September 3, 1783, which established that the thirteen colonies were sovereign and independent states. The borders were established by Article 2 of the treaty, but with a couple of issues. First, it stated that the border would run west from the Lake of the Woods to the Mississippi River - at the time, it was not known that the headwaters of the Mississippi lay south of such a line, so the border has since been taken to run south from the lake to the river. ", "Some peculiarities to point out to those familiar only with the current borders: Many states had sea-to-sea grants from the British crown that they would not give up easily, so prior to this date, they ceded this land to the federal government in exchange for their Revolutionary War debts. However, Georgia did not do so until much later, and Connecticut ceded most land but kept its Western Reserve. Virginia ceded its claim to the territory north and west of the Ohio River, and this land became unorganized territory. North Carolina also ceded its claim to its western counties, but this was not officially accepted by Congress until 1790. New York ceded its claim on the Erie Triangle to the federal government. At this point in history, all of the states except for Georgia and Virginia were at their present-day borders, except for some of the minor issues mentioned above.", "West Florida claimed a border further north than what the United States said it had. Its border had been 31\u00b0 north when Spain ceded it to the United Kingdom. The British later moved its border north to 32\u00b038\u2032 latitude, but when Spanish Florida was ceded back to Spain in the Treaty of Paris, the British cited the original border at the 31st parallel north, but Spain continued to claim the higher border. Also, the borders at the northern area of the Maine District of Massachusetts and the area northwest of Lake Superior remained disputed.", "The Wedge, disputed since the 17th century, remained a point of contention between Delaware and Pennsylvania.", "The Vermont Republic was a complex matter, with areas being claimed by New York and New Hampshire, but it existed as a de facto unrecognized independent state."]}, {"date": "1789-08-07", "id": "1789-08", "paragraphs": ["The United States Congress affirmed the organization of the Territory North West of the Ohio River, or Northwest Territory, under the terms of the Northwest Ordinance. Northwest Territory consisted of present-day Illinois, Indiana, Michigan, northeastern Minnesota, most of Ohio, and Wisconsin. The Northwest Territory had previously been organized under the Articles of Confederation on July 13, 1787, and was slightly modified under the new Constitution."]}, {"date": "1790-04-02", "id": "1790-04", "paragraphs": ["Congress accepts North Carolina 's cession of its western counties, which had initially been ceded on December 22, 1789. The land became unorganized territory. "]}, {"date": "1790-05-26", "id": "1790-05", "paragraphs": ["The Southwest Ordinance organized the Territory South of the Ohio River, or Southwest Territory, which corresponded to present-day Tennessee. "]}, {"date": "1791-03-04", "id": "1791-03", "paragraphs": ["The Vermont Republic, which had portions claimed by New York and New Hampshire and, while unrecognized by the United States, was a de facto independent country, was admitted as the 14th state, Vermont."]}, {"date": "1791-09-09", "id": "1791-09", "paragraphs": ["The District of Columbia, the nation's federal district, was formed from land granted by Maryland and Virginia ; the Virginia portion would be returned in 1847. "]}, {"date": "1792-03-03", "id": "1792-03", "paragraphs": ["The federal government sold the Erie Triangle to Pennsylvania. "]}, {"date": "1792-06-01", "id": "1792-06", "paragraphs": ["The western counties of Virginia beyond the Appalachian Mountains were split off and admitted as the 15th state, Kentucky."]}, {"date": "1794-01-11", "id": "1794-01", "paragraphs": ["In the third Nootka Convention Spain surrenders its exclusive claim to the entire Pacific Coast and acknowledges the right of Britain or other powers to use unoccupied territory."]}, {"date": "1795-10-27", "id": "1795-10", "paragraphs": ["Pinckney's Treaty, also known as the Treaty of San Lorenzo, signed on October 27, 1795, and proclaimed on August 3, 1796, settles the northern border of West Florida as the 31st parallel. "]}, {"date": "1796-06-01", "id": "1796-06", "paragraphs": ["The Southwest Territory was admitted as the 16th state, Tennessee."]}, {"date": "1798-04-07", "id": "1798-04", "paragraphs": ["Due to the Yazoo Land Fraud, an act was signed by President John Adams, authorizing him to appoint commissioners to negotiate with Georgia about ceding its western land. The act created Mississippi Territory in the region ceded by West Florida, corresponding to roughly the southern third of present-day Mississippi and Alabama except their panhandles, which were part of West Florida. "]}, {"date": "1800-07-04", "id": "1800-07", "paragraphs": ["Indiana Territory was formed from the western portion of Northwest Territory. It corresponded to present-day Illinois, Indiana, northeastern Minnesota, and Wisconsin, as well as the western half of the Lower Peninsula of Michigan and all but the eastern tip of the Upper Peninsula. Northwest Territory was left with only most of Ohio and the rest of Michigan."]}, {"date": "1800-07-10", "id": "1800-07_1", "paragraphs": ["Connecticut ceded its Western Reserve to the federal government, which made it part of Northwest Territory, and is the northeastern part of present-day Ohio. "]}, {"date": "1800-10-01", "id": "1800-10", "paragraphs": ["The secret Third Treaty of San Ildefonso transferred the colony of Louisiana from Spain to France. Its boundaries were not specified and control was not actually transferred until the Louisiana Purchase. "]}, {"date": "1802-04-26", "id": "1802-04", "paragraphs": ["Georgia finally ceded its western claims, the Yazoo Lands, to the federal government, where it became unorganized land. "]}, {"date": "1803-03-01", "id": "1803-03", "paragraphs": ["The southeastern portion of Northwest Territory was admitted as the 17th state, Ohio. The remainder of Northwest Territory was transferred to Indiana Territory. "]}, {"date": "1803-04-30", "id": "1803-04", "paragraphs": ["The Louisiana Purchase was made, expanding the United States west of the Mississippi River. There was a dispute with West Florida over how much land east of the Mississippi River it included. West of the Mississippi, it was defined as the Mississippi Basin, whose extent was not known at the time and extends slightly north of the modern Canada-US border. It consisted of the whole of present-day Arkansas, Kansas, Iowa, Missouri, Nebraska, and Oklahoma, and portions of Colorado, Louisiana, Minnesota, Montana, New Mexico, North Dakota, South Dakota, Texas and Wyoming. It also included the southernmost portions of the present-day Canadian provinces of Alberta, Manitoba, and Saskatchewan."]}, {"date": "1804-03-27", "id": "1804-03", "paragraphs": ["The unorganized land ceded by Georgia was added to Mississippi Territory, consisting of the whole of present-day Mississippi and Alabama, minus their panhandles which were still part of West Florida. "]}, {"date": "1804-10-01", "id": "1804-10", "paragraphs": ["The Louisiana Purchase was split into the District of Louisiana, which was temporarily under the authority of Indiana Territory, and the organized Territory of Orleans, which corresponded to part of present-day Louisiana with a small portion of Texas. The western border of Orleans Territory caused further conflict with New Spain, specifically over the region between the Sabine River on the west and the Arroyo Hondo (River) on the east, which became known as the Sabine Free State. This land was later confirmed as U.S. territory by the Adams-On\u00eds Treaty of 1819."]}, {"date": "1805-01-11", "id": "1805-01", "paragraphs": ["Michigan Territory was split from Indiana Territory, including the whole of the lower peninsula of present-day Michigan but only that eastern tip of the upper peninsula which was held by the Northwest Territory after Indiana Territory had been split from it. "]}, {"date": "1805-07-04", "id": "1805-07", "paragraphs": ["The District of Louisiana was organized as Louisiana Territory. "]}, {"date": "1809-03-01", "id": "1809-03", "paragraphs": ["Illinois Territory was split from Indiana Territory. Illinois Territory included present-day Illinois, northeastern Minnesota, and Wisconsin. Indiana Territory included the present-day borders of Indiana, with its western and eastern borders continuing northward; thus, it also included the central portion of the upper peninsula of Michigan, as well as Door Peninsula of present-day Wisconsin. "]}, {"date": "1810-04-01", "id": "1810-04", "paragraphs": ["The Hawaiian islands are unified as the Kingdom of Hawaii. "]}, {"date": "1810-10-27", "id": "1810-10", "paragraphs": ["By proclamation by President James Madison, the United States annexed the Baton Rouge and Mobile Districts of West Florida, declaring them part of the Louisiana Purchase. These had, 90 days earlier, declared independence as the Republic of West Florida. "]}, {"date": "1812-04-30", "id": "1812-04", "paragraphs": ["Most of the Territory of Orleans was admitted as the 18th state, Louisiana. The rest of the territory (the northwestern tip) was ceded to Louisiana Territory."]}, {"date": "1812-05-12", "id": "1812-05", "paragraphs": ["The federal government annexed a part of West Florida, the Mobile District, to Mississippi Territory, making the territory correspond to present-day Alabama and Mississippi. "]}, {"date": "1812-06-04", "id": "1812-06", "paragraphs": ["Louisiana Territory, having the same name as a state, was renamed to Missouri Territory. "]}, {"date": "1813-04-17", "id": "1813-04", "paragraphs": ["Republican Army of the North captured San Antonio, Texas, assassinated the governor Manuel Mar\u00eda de Salcedo, proclaimed Texas an independent nation, and issued Texas's first constitution on this date. Spanish forces recaptured the province later that year and executed any Tejanos accused of having Republican tendencies. By 1820 fewer than 2000 Hispanic citizens remained in Spanish Texas."]}, {"date": "1816-12-11", "id": "1816-12", "paragraphs": ["The southern portion of Indiana Territory was admitted as the 19th state, Indiana. The remainder became unorganized. "]}, {"date": "1817-03-03", "id": "1817-03", "paragraphs": ["Alabama Territory was split from Mississippi Territory ; both correspond to their present-day counterparts. "]}, {"date": "1817-12-10", "id": "1817-12", "paragraphs": ["Mississippi Territory was admitted as the 20th state, Mississippi."]}, {"date": "1818-10-20", "id": "1818-10", "paragraphs": ["The Treaty of 1818 established the 49th parallel north west of the Lake of the Woods as the border with British-held lands, and Oregon Country was established as a shared land between the United States and United Kingdom. Oregon Country consisted of most of present-day Idaho and Oregon, all of Washington, and a portion of Montana, as well as the southern part of the Canadian province of British Columbia. The treaty transferred the Red River Basin to the United States, consisting of northwestern Minnesota, northeastern North Dakota, and the northeastern tip of South Dakota."]}, {"date": "1818-12-03", "id": "1818-12", "paragraphs": ["The southern portion of Illinois Territory was admitted as the 21st state, Illinois. The remainder was reassigned to Michigan Territory. The unorganized lands which had been a part of Indiana Territory prior to the admission of Indiana as a state were also assigned to Michigan Territory. "]}, {"date": "1819-03-02", "id": "1819-03", "paragraphs": ["The southern part of Missouri Territory was organized as Arkansaw Territory, consisting of present-day Arkansas as well as part of Oklahoma. It was not officially spelled Arkansas until later."]}, {"date": "1819-12-14", "id": "1819-12", "paragraphs": ["Alabama Territory was admitted as the 22nd state, Alabama."]}, {"date": "1820-03-16", "id": "1820-03", "paragraphs": ["The Maine District of Massachusetts was split off and admitted as the 23rd state, Maine, as part of the Missouri Compromise. The northern border of Maine was not settled until 1842."]}, {"date": "1821-07-10", "id": "1821-07", "paragraphs": ["The Adams-On\u00eds Treaty or Transcontinental Treaty came into effect, establishing a defined border between the United States and New Spain. The treaty ceded Spain's claims to Oregon Country to the United States and American claims to Texas to Spain; moved portions of present-day Colorado, Oklahoma, and Wyoming, and all of New Mexico and Texas, to New Spain; and all of Spanish Florida to the United States. The new borders intruded on Arkansaw Territory's Miller County, created on April 1, 1820, which dipped below the Red River and into land now ceded to Spain. However, the remoteness of the region caused no serious conflict with Spain. "]}, {"date": "1821-08-10", "id": "1821-08", "paragraphs": ["The southeastern corner of Missouri Territory was admitted as the 24th state, Missouri. The remainder became unorganized. Missouri did not include its northwestern triangle at this point, that being added later in the Platte Purchase. "]}, {"date": "1821-09-16", "id": "1821-09", "paragraphs": ["Ukase of 1821 attempts to forbid non-Russian ships from approaching the Northwest Coast. Only attempt at enforcement is seizure of the U.S. brig Pearl in 1822. U.S. reacts with the Monroe Doctrine in 1823. "]}, {"date": "1821-09-27", "id": "1821-09_1", "paragraphs": ["The Viceroyalty of New Spain achieved independence as Mexico. Spanish Texas became Mexican Texas."]}, {"date": "1822-03-30", "id": "1822-03", "paragraphs": ["East Florida and the portion of West Florida not already part of other states were combined and organized as Florida Territory, which corresponded to present-day Florida. Around this time, the official spelling of Arkansaw Territory became Arkansas Territory. "]}, {"date": "1824-11-15", "id": "1824-11", "paragraphs": ["Arkansas Territory was shrunk, the western portion becoming unorganized. "]}, {"date": "1825-01-12", "id": "1825-01", "paragraphs": ["Russo-American Treaty of 1824 gave Ru
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment