Last active
December 15, 2015 13:28
-
-
Save timelyportfolio/5267175 to your computer and use it in GitHub Desktop.
map with parcoord forked from http://dexvis.wordpress.com
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// forked from http://dexvis.com/vis/blog/2013/mar/reusable6/html/ParallelCoordinates3.html | |
function DexComponent(userConfig, defaultConfig) | |
{ | |
// This holds our event registry. | |
this.registry = {}; | |
this.debug = false; | |
//console.log("Instantiating dex component..."); | |
// Instantiate from another component | |
if (userConfig instanceof DexComponent) | |
{ | |
this.config = getConfig(userConfig.config, defaultConfig); | |
} | |
else | |
{ | |
this.config = getConfig(userConfig, defaultConfig); | |
//console.dir(this.config); | |
} | |
} | |
DexComponent.prototype.attr = function(name, value) | |
{ | |
if (arguments.length == 1) | |
{ | |
return this.config[name]; | |
} | |
else if (arguments.length == 2) | |
{ | |
this.config[name] = value; | |
} | |
return this; | |
}; | |
DexComponent.prototype.dump = function(message) | |
{ | |
console.log("========================"); | |
if (arguments.length == 1) | |
{ | |
console.log(message); | |
console.log("========================"); | |
} | |
console.log("=== CONFIG ==="); | |
console.dir(this.config); | |
console.log("=== REGISTRY ==="); | |
console.dir(this.registry); | |
}; | |
DexComponent.prototype.addListener = function(eventType, target, method) | |
{ | |
var targets; | |
if (this.debug) | |
{ | |
console.log("REGISTERING TARGET: " + eventType + "="+ target); | |
} | |
if (!this.registry.hasOwnProperty(eventType)) | |
{ | |
this.registry[eventType] = []; | |
} | |
this.registry[eventType].push({ target : target, method : method }); | |
//console.log("this.registry"); | |
//console.dir(eventthis.registry); | |
}; | |
DexComponent.prototype.notify = function(event) | |
{ | |
var targets; | |
if (this.debug) | |
{ | |
console.log("notify: " + event.type); | |
} | |
if (!this.registry.hasOwnProperty(event.type)) | |
{ | |
return; | |
} | |
event.source = this; | |
targets = this.registry[event.type]; | |
//console.log("TARGETS: " + targets.length); | |
//console.dir(targets); | |
for (var i=0; i<targets.length; i++) | |
{ | |
//console.dir("Calling Target: " + targets[i]["target"]); | |
targets[i]["method"](event, targets[i]["target"]); | |
} | |
}; | |
DexComponent.prototype.render = function() | |
{ | |
console.log("Rendering component..."); | |
}; | |
DexComponent.prototype.update = function() | |
{ | |
console.log("Updating component..."); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//http://dexvis.com/vis/blog/2013/mar/reusable6/html/ParallelCoordinates3.html | |
var dex = | |
{ | |
version : "0.6", | |
matrix : {}, | |
datagen : {}, | |
array : {}, | |
csv : {} | |
}; | |
dex.datagen.randomMatrix = function(spec) | |
{ | |
//{"rows":10, "columns": 4, "min", 0, "max":100}) | |
var matrix = []; | |
var range = spec.max - spec.min; | |
for (var ri = 0; ri<spec.rows; ri++) | |
{ | |
var row = []; | |
for (var ci=0; ci<spec.columns;ci++) | |
{ | |
row.push(Math.random() * range + spec.min); | |
} | |
matrix.push(row); | |
} | |
return matrix; | |
} | |
function getConfig(userConfig, defaultConfig) | |
{ | |
var config = clone(defaultConfig); | |
//console.dir(config); | |
//console.dir(defaultConfig); | |
// If we have parameters, override the defaults. | |
if (userConfig !== 'undefined') | |
{ | |
for (var option in userConfig) | |
{ | |
config[option] = userConfig[option]; | |
} | |
} | |
//console.dir(config); | |
return config; | |
} | |
dex.array.slice = function(array, rows) | |
{ | |
var slice = []; | |
for (var i = 0; i<rows.length; i++) | |
{ | |
slice.push(array[rows[i]]); | |
} | |
return slice; | |
} | |
dex.matrix.slice = function(matrix, columns, rows) | |
{ | |
var slice = []; | |
if (arguments.length === 3) | |
{ | |
for (var ri=0; ri < rows.length; ri++) | |
{ | |
slice.push(dex.array.slice(matrix[rows[ri]])); | |
} | |
} | |
else | |
{ | |
for (var ri=0; ri < matrix.length; ri++) | |
{ | |
//console.log("RI: " + ri); | |
//console.dir(dex.array.slice(matrix[ri], columns)); | |
slice.push(dex.array.slice(matrix[ri], columns)); | |
} | |
} | |
return slice; | |
} | |
dex.matrix.flatten = function(matrix) | |
{ | |
var array = []; | |
for (var ri=0; ri<matrix.length; ri++) | |
{ | |
for (var ci=0; ci<matrix[ri].length;ci++) | |
{ | |
array.push(matrix[ri][ci]); | |
} | |
} | |
return array; | |
} | |
dex.matrix.extent = function(data, indices) | |
{ | |
var values = data; | |
if (arguments.length === 2) | |
{ | |
values = dex.matrix.slice(data, indices); | |
return d3.extent(dex.matrix.flatten(values)); | |
} | |
} | |
// Combine each column in matrix1 with each column in matrix2. | |
dex.matrix.combine = function(matrix1, matrix2) | |
{ | |
var result = []; | |
// Iterate over the rows in matrix1: | |
for (var ri=0; ri<matrix1.length; ri++) | |
{ | |
// Iterate over the columns in matrix2: | |
for (var oci=0; oci<matrix1[ri].length; oci++) | |
{ | |
// Iterate over the columns in matrix2: | |
for (var ici=0; ici<matrix2[ri].length; ici++) | |
{ | |
result.push([matrix1[ri][oci], matrix2[ri][ici], oci, ici]); | |
} | |
} | |
} | |
return result; | |
} | |
dex.csv.createMap = function(header, data, keyIndex) | |
{ | |
var map = {}; | |
for (var ri=0; ri<data.length; ri++) | |
{ | |
if (data[ri].length == header.length) | |
{ | |
var rowMap = {}; | |
for (var ci=0; ci<header.length; ci++) | |
{ | |
rowMap[header[ci]] = data[ri][ci]; | |
} | |
map[data[ri][keyIndex]] = rowMap; | |
} | |
} | |
return map; | |
}; | |
dex.csv.toJson = function(columnNames, data) | |
{ | |
var jsonData = []; | |
for (var ri=0; ri<data.length; ri++) | |
{ | |
var jsonRow = {}; | |
for (var ci=0; ci<data[ri].length; ci++) | |
{ | |
jsonRow[columnNames[ci]] = data[ri][ci]; | |
} | |
jsonData.push(jsonRow); | |
} | |
return jsonData; | |
}; | |
dex.csv.createRowMap = function(header, data, keyIndex) | |
{ | |
var map = {}; | |
for (var ri=0; ri<data.length; ri++) | |
{ | |
if (data[ri].length == header.length) | |
{ | |
map[data[ri][keyIndex]] = data[ri]; | |
} | |
} | |
return map; | |
} | |
function getExtent(array, indices) | |
{ | |
var values = getArrayValues(array, indices); | |
var max = Math.max.apply(null, values); | |
var min = Math.min.apply(null, values); | |
console.log("EXTENT:"); | |
console.dir(values); | |
console.dir([min, max]); | |
return [ min, max ]; | |
} | |
function clone(obj) | |
{ | |
if (obj === null || typeof obj !== 'object') | |
{ | |
return obj; | |
} | |
var temp = obj.constructor(); | |
// give temp the original obj's constructor | |
for (var key in obj) | |
{ | |
temp[key] = clone(obj[key]); | |
} | |
return temp; | |
} | |
/* Dex Utilities */ | |
function colorToHex(color) | |
{ | |
if (color.substr(0, 1) === '#') | |
{ | |
return color; | |
} | |
//console.log("COLOR: " + color) | |
var digits = /rgb\((\d+),(\d+),(\d+)\)/.exec(color); | |
//console.log("DIGITS: " + digits); | |
var red = parseInt(digits[1]); | |
var green = parseInt(digits[2]); | |
var blue = parseInt(digits[3]); | |
var rgb = blue | (green << 8) | (red << 16); | |
return '#' + rgb.toString(16); | |
}; | |
function isNumber(n) | |
{ | |
return !isNaN(parseFloat(n)) && isFinite(n); | |
} | |
function getHeader(data) | |
{ | |
return data[0]; | |
} | |
function getColumn(data, columnNumber) | |
{ | |
var values = []; | |
for (var i=1; i<data.length; i++) | |
{ | |
values.push(data[i][columnNumber]); | |
} | |
return values; | |
} | |
dex.csv.getNumericColumnNames = function(columnNames, data) | |
{ | |
var possibleNumeric = {}; | |
var i, j; | |
var numericColumns = []; | |
for (i=0; i<columnNames.length; i++) | |
{ | |
possibleNumeric[columnNames[i]] = true; | |
} | |
// Iterate thru the data, skip the header. | |
for (ri=0; ri<data.length; ri++) | |
{ | |
for (ci=0; ci<data[ri].length && ci<columnNames.length; ci++) | |
{ | |
if (possibleNumeric[columnNames[ci]] && !isNumber(data[ri][ci])) | |
{ | |
possibleNumeric[columnNames[ci]] = false; | |
} | |
} | |
} | |
for (ci=0; ci<columnNames.length; ci++) | |
{ | |
if (possibleNumeric[columnNames[ci]]) | |
{ | |
numericColumns.push(columnNames[ci]); | |
} | |
} | |
return numericColumns; | |
} | |
function getNumericIndices(data) | |
{ | |
var header = getHeader(data); | |
var possibleNumeric = {}; | |
var i, j; | |
var numericIndices = []; | |
for (i=0; i<header.length; i++) | |
{ | |
possibleNumeric[header[i]] = true; | |
} | |
// Iterate thru the data, skip the header. | |
for (i=1; i<data.length; i++) | |
{ | |
for (j=0; j<data[i].length && j<header.length; j++) | |
{ | |
if (possibleNumeric[header[j]] && !isNumber(data[i][j])) | |
{ | |
possibleNumeric[header[j]] = false; | |
} | |
} | |
} | |
for (i=0; i<header.length; i++) | |
{ | |
if (possibleNumeric[header[i]]) | |
{ | |
numericIndices.push(i); | |
} | |
} | |
return numericIndices; | |
} | |
function isNumericColumn(data, columnNum) | |
{ | |
for (var i=1; i<data.length; i++) | |
{ | |
if (!isNumber(data[i][columnNum])) | |
{ | |
return false; | |
} | |
} | |
return true; | |
} | |
function getMax(data, columnNum) | |
{ | |
var maxValue = data[1][columnNum]; | |
if (isNumericColumn(data, columnNum)) | |
{ | |
maxValue = parseFloat(data[1][columnNum]); | |
for (var i=2; i<data.length; i++) | |
{ | |
if (maxValue < parseFloat(data[i][columnNum])) | |
{ | |
maxValue = parseFloat(data[i][columnNum]); | |
} | |
} | |
} | |
else | |
{ | |
for (var i=2; i<data.length; i++) | |
{ | |
if (maxValue < data[i][columnNum]) | |
{ | |
maxValue = data[i][columnNum]; | |
} | |
} | |
} | |
return maxValue; | |
} | |
function getMin(data, columnNum) | |
{ | |
var minValue = data[1][columnNum]; | |
if (isNumericColumn(data, columnNum)) | |
{ | |
minValue = parseFloat(data[1][columnNum]); | |
for (var i=2; i<data.length; i++) | |
{ | |
if (minValue > parseFloat(data[i][columnNum])) | |
{ | |
minValue = parseFloat(data[i][columnNum]); | |
} | |
} | |
} | |
else | |
{ | |
for (var i=2; i<data.length; i++) | |
{ | |
if (minValue > data[i][columnNum]) | |
{ | |
minValue = data[i][columnNum]; | |
} | |
} | |
} | |
return minValue; | |
} | |
function getJsonFromCsv(data) | |
{ | |
var header = getHeader(data); | |
var i,j; | |
var json = []; | |
for (i=1;i<data.length;i++) | |
{ | |
var row = {}; | |
for (j=0;j<data[i].length && j<header.length;j++) | |
{ | |
row[header[j]] = data[i][j]; | |
} | |
json.push(row); | |
} | |
return json; | |
} | |
function getFill(colorScheme, numColors) | |
{ | |
if (colorScheme == "1") | |
{ | |
return d3.scale.category10(); | |
} | |
else if (colorScheme == "2") | |
{ | |
return d3.scale.category20(); | |
} | |
else if (colorScheme == "3") | |
{ | |
return d3.scale.category20b(); | |
} | |
else if (colorScheme == "4") | |
{ | |
return d3.scale.category20c(); | |
} | |
else if (colorScheme == "HiContrast") | |
{ | |
return d3.scale.ordinal().range(colorbrewer[colorScheme][9]); | |
} | |
else if (colorScheme in colorbrewer) | |
{ | |
//console.log("LENGTH: " + len); | |
var effColors = Math.pow(2, Math.ceil(Math.log(numColors) / Math.log(2))); | |
//console.log("EFF LENGTH: " + len); | |
// Find the best cmap: | |
if (effColors > 128) | |
{ | |
effColors = 256; | |
} | |
for (var c=effColors; c >= 2; c--) | |
{ | |
if (colorbrewer[colorScheme][c]) | |
{ | |
return d3.scale.ordinal().range(colorbrewer[colorScheme][c]); | |
} | |
} | |
for (var c=effColors; c <= 256; c++) | |
{ | |
if (colorbrewer[colorScheme][c]) | |
{ | |
return d3.scale.ordinal().range(colorbrewer[colorScheme][c]); | |
} | |
} | |
return d3.scale.category20(); | |
} | |
else | |
{ | |
return d3.scale.category20(); | |
} | |
} | |
function OrdinalHorizontalLegend(config) | |
{ | |
// Default parameters. | |
var p = | |
{ | |
labels : [ "A", "B", "C" ], | |
parent : null, | |
xoffset : 10, | |
yoffset : 20, | |
cellWidth : 30, | |
cellHeight : 20, | |
tickLength : 25, | |
caption : "Legend", | |
color : d3.scale.category20c(), | |
captionFontSize : 14, | |
captionXOffset : 0, | |
captionYOffset : -6 | |
}; | |
// If we have parameters, override the defaults. | |
if (config !== 'undefined') | |
{ | |
for (var prop in config) | |
{ | |
p[prop] = config[prop]; | |
} | |
} | |
function chart() | |
{ | |
// Create our x scale | |
var x = d3.scale.ordinal() | |
.domain(p.labels) | |
.range(d3.range(p.labels.length).map(function(i) { return i * p.cellWidth; })); | |
// Create the x axis. | |
var xAxis = d3.svg.axis() | |
.scale(x) | |
.orient("bottom") | |
.tickSize(p.tickLength) | |
.tickPadding(10) | |
.tickValues(p.labels) | |
.tickFormat(function(d) { return d; }); | |
// Append a graphics node to the supplied svg node. | |
var g = p.parent.append("g") | |
.attr("class", "key") | |
.attr("transform", "translate(" + p.xoffset + "," + p.yoffset + ")"); | |
// Draw a colored rectangle for each ordinal range. | |
g.selectAll("rect") | |
.data(p.labels) | |
.enter().append("rect") | |
.attr("height", p.cellHeight) | |
.attr("x", function(d, i) { return x(i); }) | |
.attr("width", function(d) { return p.cellWidth; }) | |
.style("fill", function(d, i) | |
{ | |
return p.color(i); | |
}); | |
// Add the caption. | |
g.call(xAxis).append("text") | |
.attr("class", "caption") | |
.attr("y", p.captionYOffset) | |
.attr("x", p.captionXOffset) | |
.text(p.caption) | |
.style("font-size", p.captionFontSize); | |
}; | |
// Use this routine to retrieve and update attributes. | |
chart.attr = function(name, value) | |
{ | |
if (arguments.length == 1) | |
{ | |
return p[name]; | |
} | |
else if (arguments.length == 2) | |
{ | |
p[name] = value; | |
} | |
return chart; | |
} | |
chart.update = function() | |
{ | |
} | |
return chart; | |
} | |
function VerticalLegend(config) | |
{ | |
// Default parameters. | |
var p = | |
{ | |
labels : [ "A", "B", "C" ], | |
parent : null, | |
xoffset : 50, | |
yoffset : 30, | |
cellWidth : 30, | |
cellHeight : 20, | |
tickLength : 5, | |
caption : "Legend", | |
color : d3.scale.category20c(), | |
captionFontSize : 14, | |
captionXOffset : -30, | |
captionYOffset : -20 | |
}; | |
// If we have parameters, override the defaults. | |
if (config !== 'undefined') | |
{ | |
for (var prop in config) | |
{ | |
p[prop] = config[prop]; | |
} | |
} | |
function chart() | |
{ | |
// Create our x scale | |
var y = d3.scale.ordinal() | |
.domain(p.labels) | |
.range(d3.range(p.labels.length).map(function(i) { return i * p.cellHeight; })); | |
// Create the x axis. | |
var yAxis = d3.svg.axis() | |
.scale(y) | |
.orient("left") | |
.tickSize(p.tickLength) | |
.tickPadding(10) | |
.tickValues(p.labels) | |
.tickFormat(function(d) { return d; }); | |
// Append a graphics node to the supplied svg node. | |
var g = p.parent.append("g") | |
.attr("class", "key") | |
.attr("transform", "translate(" + p.xoffset + "," + p.yoffset + ")"); | |
// Draw a colored rectangle for each ordinal range. | |
g.selectAll("rect") | |
.data(p.labels) | |
.enter().append("rect") | |
.attr("height", p.cellHeight) | |
.attr("y", function(d, i) { return y(i); }) | |
.attr("width", p.cellWidth) | |
.style("fill", function(d, i) | |
{ | |
return p.color(i); | |
}); | |
// Add the caption. | |
g.call(yAxis).append("text") | |
.attr("class", "caption") | |
.attr("y", p.captionYOffset) | |
.attr("x", p.captionXOffset) | |
.text(p.caption) | |
.style("font-size", p.captionFontSize); | |
}; | |
// Use this routine to retrieve and update attributes. | |
chart.attr = function(name, value) | |
{ | |
if (arguments.length == 1) | |
{ | |
return p[name]; | |
} | |
else if (arguments.length == 2) | |
{ | |
p[name] = value; | |
} | |
return chart; | |
} | |
chart.update = function() | |
{ | |
} | |
return chart; | |
} | |
function csvToMapArray(header, data) | |
{ | |
var mapArray = []; | |
for (var i=0; i<data.length; i++) | |
{ | |
var row = {}; | |
for (var j=0; j<header.length; j++) | |
{ | |
row[header[j]] = data[i][j] | |
} | |
mapArray.push(row); | |
} | |
return mapArray; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--all credit goes to http://dexvis.wordpress.com | |
only very minor modifications were made to change the behavior or the brush--> | |
<!DOCTYPE html> | |
<meta charset="utf-8"> | |
<style> | |
#StateMap path { | |
fill: #ccc; | |
stroke: #fff; | |
stroke-width: .5px; | |
} | |
#StateMap path:hover { | |
fill: red; | |
} | |
#ParChart textarea | |
{ | |
width:100%; | |
} | |
#ParChart .textwrapper | |
{ | |
border:1px solid #999999; | |
margin:5px 0; | |
padding:5px; | |
} | |
#ParChart path | |
{ | |
fill: none; | |
/*stroke: #ccc;*/ | |
stroke-opacity: .9; | |
shape-rendering: crispEdges; | |
} | |
#ParChart .foreground path | |
{ | |
fill: none; | |
stroke: steelblue; | |
stroke-opacity: .9; | |
} | |
#ParChart .brush .extent | |
{ | |
fill-opacity: .3; | |
stroke: #fff; | |
shape-rendering: crispEdges; | |
} | |
#ParChart .axis line, #ParChart .axis path | |
{ | |
fill: none; | |
stroke: #000; | |
shape-rendering: crispEdges; | |
} | |
#ParChart .axis text | |
{ | |
text-shadow: 0 1px 0 #fff; | |
} | |
</style> | |
<body> | |
<script src="http://d3js.org/d3.v3.min.js"></script> | |
<script src="http://d3js.org/topojson.v0.min.js"></script> | |
<script src="DexUtils.js"></script> | |
<script src="DexComponent.js"></script> | |
<script src="VerticalLegend.js"></script> | |
<script src="ParallelCoordinates.js"></script> | |
<script src="USStateMap.js"></script> | |
<center><h1>State Taxes For Q3 2012</h1></center> | |
<script> | |
// Create an SVG for our chart. | |
var svg = d3.select("body").append("svg") | |
.attr("width", 1500) | |
.attr("height", 1000) | |
.append("g") | |
.attr("transform", "translate(40,20)"); | |
var labels = [ | |
"State", "Property", "Sales", "Alcohol", | |
"Amuse", "Ins", "Gas", "P-Mut", "Util", | |
"Tobacco", "Other Sales", "Alc Lic", | |
"Amuse Lic", "Corp Lic", "Hunt/Fish Lic", | |
"Vehicle Lic", "Drivers Lic", "Util Lic", | |
"Biz Lic", "Other Lic", "Income", "Corp", "Death/Gift", | |
"Doc/Stock", "Severance", "Other", "Total"]; | |
var stateData = | |
[ | |
["Alabama", 12, 562, 44, 0, 108, 146, 0, 194, 34, 79, 0, 0, 10, 5, 47, 6, 3, 27, 0, 743, 76, 0, 10, 26, 0, 2134], | |
["Alaska", 0, 0, 9, 0, 14, 10, 0, 0, 19, 2, 0, 0, 0, 10, 28, 0, 0, 5, 3, 0, 242, 0, 0, 744, 0, 1088], | |
["Arizona", 194, 1193, 15, 0, 109, 199, 0, 5, 81, 25, 1, 0, 17, 6, 44, 8, 5, 30, 0, 893, 176, 0, 0, 7, 0, 3009], | |
["Arkansas", 109, 713, 12, 8, 23, 120, 1, 0, 61, 59, 1, 0, 2, 8, 38, 4, 19, 31, 0, 659, 96, 0, 8, 16, 6, 1993], | |
["California", 494, 7431, 68, 0, 528, 1403, 4, 160, 162, 1024, 16, 4, 13, 23, 773, 67, 98, 1055, 1, 11565, 1080, 1, 0, 8, 0, 25977], | |
["District of Columbia", 934, 261, 1, 0, 2, 6, 0, 36, 10, 16, 0, 0, 0, 0, 9, 2, 0, 7, 12, 369, 84, 10, 99, 0, 0, 1857], | |
["Florida", 0, 5031, 103, 34, 5, 828, 3, 714, 96, 158, 2, 0, 25, 3, 272, 84, 14, 48, 2, 0, 440, 0, 433, 11, 0, 8308], | |
// This is a test row... | |
//["Florida",0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25], | |
["Georgia", 2, 1315, 37, 0, 95, 238, 0, 0, 54, 0, 0, 4, 12, 6, 81, 16, 0, 18, 2, 2276, 105, 0, 0, 0, 0, 4262], | |
["Illinois", 11, 1994, 74, 168, 66, 330, 2, 389, 156, 435, 3, 5, 74, 10, 425, 25, 9, 83, 5, 3620, 562, 97, 13, 0, 0, 8555], | |
["Indiana", 0, 1726, 12, 168, 56, 203, 1, 5, 111, 3, 3, 1, 2, 3, 24, 44, 0, 8, 2, 1180, 238, 41, 0, 0, 0, 3831], | |
["Kansas", 5, 729, 30, 0, 4, 113, 0, 0, 25, 10, 1, 0, 5, 3, 38, 6, 1, 0, 1, 704, 64, 1, 0, 29, 0, 1768], | |
["Kentucky", 66, 761, 30, 0, 31, 207, 1, 17, 66, 164, 2, 0, -2, 7, 39, 4, 0, 2, 1, 902, 160, 9, 1, 74, 0, 2543], | |
["Louisiana", 12, 689, 14, 176, 175, 175, 1, 2, 47, 17, 0, 0, 25, 8, 7, 2, 2, 17, 1, 697, 78, 0, 0, 201, 0, 2346], | |
["Maine", 21, 210, 5, 14, 13, 46, 1, 12, 37, 14, 1, 0, 1, 4, 25, 3, 0, 24, 2, 312, 37, 6, 3, 0, 0, 792], | |
["Maryland", 486, 685, 5, 2, 113, 85, 0, 33, 83, 317, 0, 0, 9, 5, 107, 7, 0, 36, 0, 1109, 245, 48, 34, 0, 10, 3419], | |
["Massachusetts", 1, 1323, 22, 1, 90, 176, 0, 5, 143, 114, 0, 0, 2, 1, 67, 17, 0, 57, 21, 2908, 495, 73, 40, 0, 28, 5584], | |
["Michigan", 507, 2923, 44, 39, 137, 439, 1, 12, 330, 350, -2, 0, 4, 18, 224, 16, 3, 58, 48, 2454, 195, 0, 79, 20, 0, 7899], | |
["Minnesota", 16, 1239, 15, 9, 76, 240, 0, 0, 85, 673, 0, 1, 2, 13, 150, 11, 0, 73, 17, 2015, 251, 38, 26, 10, 0, 4961], | |
["Mississippi", 0, 645, 11, 33, 26, 108, 0, 3, 39, 26, 1, 4, 24, 2, 36, 8, 9, 19, 9, 361, 67, 0, 0, 25, 0, 1456], | |
["Missouri", 1, 808, 9, 101, 58, 183, 0, 0, 26, 34, 0, 0, 10, 5, 59, 5, 6, 37, 19, 1206, 70, 0, 1, 0, 0, 2637], | |
["Montana", 12, 0, 7, 14, 15, 41, 0, 12, 24, 9, 0, 4, 0, 9, 25, 2, 0, 14, 1, 232, 42, 0, 0, 69, 0, 533], | |
["Nebraska", 0, 379, 8, 1, 18, 90, 0, 14, 17, 43, 0, 0, 0, 3, 18, 1, 0, 3, 0, 475, 50, 0, 2, 1, 0, 1122], | |
["Nevada", 11, 286, 3, 179, 2, 25, 0, 4, 10, 3, 0, 3, 15, 1, 29, 5, 0, 42, 0, 0, 0, 0, 2, 0, 0, 618], | |
["New Hampshire", 7, 0, 4, 0, 0, 36, 0, 20, 56, 93, 1, 0, 0, 2, 22, 3, 2, 29, 0, 15, 124, 0, 26, 0, 0, 441], | |
["New Jersey", 0, 1307, 21, 62, 15, 90, 0, 98, 184, 110, 1, 21, 49, 1, 148, 13, 0, 112, 0, 1807, 443, 137, 56, 0, 0, 4676], | |
["New Mexico", 17, 152, 7, 5, 3, 17, 0, 3, 8, 25, 0, 0, 4, 6, 3, 1, 0, 5, 19, 78, 3, 0, 0, 106, 1, 463], | |
["North Dakota", 0, 335, 2, 1, 8, 57, 0, 3, 8, 37, 0, 0, 0, 2, 22, 1, 0, 14, 0, 98, 40, 0, 0, 513, 0, 1142], | |
["Ohio", 0, 1900, 26, 0, 9, 447, 2, 292, 162, 2, 12, 105, 413, 5, 138, 63, 1, 124, 3, 2492, 47, 2, 0, 4, 0, 6249], | |
["Oregon", 8, 0, 5, 0, 20, 181, 1, 2, 65, 0, 1, 0, 7, 13, 163, 6, 2, 65, 1, 1518, 114, 26, 1, 2, 0, 2200], | |
["Pennsylvania", 4, 2327, 79, 365, 5, 539, 3, 36, 287, 30, 4, 6, 129, 31, 198, 16, 23, 218, 3, 2342, 401, 181, 105, 0, 4, 7337], | |
["Rhode Island", 0, 233, 3, 0, 2, 25, 0, 3, 37, 138, 0, 0, 1, 0, 14, 1, 0, 9, 0, 267, 21, 7, 2, 0, 2, 767], | |
["South Carolina", 0, 517, 28, 9, 37, 135, 0, 25, 4, 91, 3, 0, 13, 9, 21, 9, 0, 36, 3, 529, 53, 0, 5, 0, 0, 1526], | |
["Vermont", 10, 88, 6, 0, 8, 27, 0, 0, 20, 91, 0, 0, 0, 1, 17, 2, 0, 2, 0, 147, 24, 7, 2, 0, 1, 456], | |
["Virginia", 0, 794, 24, 0, 107, 293, 0, 27, 47, 170, 3, 0, 19, 7, 112, 17, 0, 58, 1, 2580, 162, 0, 91, 0, 25, 4535], | |
["Washington", 575, 2788, 62, 0, 106, 260, 1, 82, 122, 109, 3, 2, 7, 10, 115, 19, 1, 73, 109, 0, 0, 22, 129, 7, 0, 4602], | |
["West Virginia", 2, 314, 5, 17, 36, 112, 1, 37, 27, 120, 0, 1, 1, 0, 1, 27, 0, 3, 1, 434, 68, 0, 2, 116, 0, 1326], | |
["Wisconsin", 0, 762, 9, 0, 22, 183, 0, 41, 118, 114, 0, 0, 4, 15, 96, 11, 0, 74, 1, 1535, 236, 0, 8, 0, 2, 3231], | |
["Wyoming", 14, 191, 1, 0, 4, 16, 0, 2, 7, 0, 0, 0, 3, 20, 20, 1, 0, 6, 0, 0, 0, 0, 0, 0, 1, 287], | |
["Colorado", 0, 617, 10, 16, 46, 166, 0, 3, 52, 8, 2, 0, 4, 16, 121, 8, 0, 9, 0, 1220, 155, 0, 0, 33, 0, 2489], | |
["Connecticut", 0, 482, 8, 99, 39, 84, 2, 5, 89, 8, 2, 0, 7, 1, 49, 11, 0, 28, 0, 978, 65, 31, 24, 0, 1, 2014], | |
["Hawaii", 0, 739, 11, 0, 32, 24, 0, 42, 29, 39, 0, 0, 0, 0, 36, 0, 10, 5, 0, 435, 26, 1, 12, 0, 0, 1443], | |
["Idaho", 0, 350, 2, 0, 12, 64, 0, 1, 13, 3, 0, 0, 0, 10, 28, 3, 8, 11, 1, 288, 39, 0, 0, 2, 1, 837], | |
["Iowa", 0, 436, 3, 56, 47, 41, 1, 0, 51, 0, 3, 6, 5, 4, 120, 3, 4, 28, 0, 572, 38, 5, 2, 0, 0, 1428], | |
["New York", 0, 3055, 67, 0, 285, 420, 6, 214, 409, 1289, 14, 0, 18, 28, 317, 32, 3, 57, 0, 8737, 922, 258, 227, 0, 306, 16666], | |
["North Carolina", 0, 1446, 86, 4, 8, 496, 0, 104, 74, 163, 1, 0, 74, 5, 143, 29, 0, 45, 2, 2688, 294, 18, 11, 0, 0, 5693], | |
["Oklahoma", 0, 642, 30, 6, 55, 106, 0, 11, 75, 4, 0, 1, 27, 3, 174, 4, 0, 0, 9, 704, 123, 0, 4, 111, 17, 2105], | |
["South Dakota", 0, 207, 4, 0, 15, 42, 0, 2, 17, 18, 0, 0, 1, 8, 17, 1, 0, 20, 9, 0, 11, 0, 0, 3, 0, 377], | |
["Tennessee", 0, 1759, 31, 0, 150, 213, 0, 10, 71, 37, 3, 0, 143, 4, 63, 11, 0, 38, 1, 4, 256, 26, 42, 1, 9, 2874], | |
["Texas", 0, 6392, 239, 8, 627, 818, 2, 191, 371, 1469, 16, 3, 242, 44, 484, 67, 4, 144, 40, 0, 0, 29, 0, 855, 0, 12044], | |
["Utah", 0, 494, 10, 0, 26, 86, 0, 6, 32, 42, 0, 0, 0, 7, 41, 4, 0, 12, 0, 592, 68, 0, 0, 20, 0, 1441], | |
["Delaware", 0, 0, 5, 0, 15, 24, 0, 14, 30, 20, 0, 0, 112, 1, 13, 2, 0, 84, 16, 273, 63, 2, 76, 0, 1, 749] | |
]; | |
//get each tax as a percent of total | |
stateData.forEach(function (d) { d.slice(1,d.length).forEach(function (dd,ii) { d[ii+1] = dd/d[d.length-1] } )}) | |
var stateMap = dex.csv.createRowMap(labels, stateData, 0); | |
// Configure a chart. | |
var map = new USStateMap( | |
{ | |
'parent': svg, | |
'id': 'StateMap', | |
'xoffset': 150 | |
} | |
); | |
var pcChart = new ParallelCoordinates( | |
{ | |
'parent': svg, | |
'id': "ParChart", | |
'columnNames': labels, | |
'data': [], | |
'normalize': false, | |
'opacity': 100, | |
'xoffset': 20, | |
'yoffset': 520, | |
'width': 1200, | |
'height': 400, | |
'axisLabels': | |
{ | |
'stagger': true, | |
'yoffset': -9, | |
'staggeredYOffset': -25 | |
} | |
} | |
); | |
var selectedStates = {}; | |
map.addListener("selectState", pcChart, function (chartEvent) { | |
console.dir("Selected: " + chartEvent.state); | |
if (stateMap[chartEvent.state] != null) { | |
d3.selectAll("#ParChart").remove(); | |
selectedStates[chartEvent.state] = true; | |
var pcData = [] | |
for (var state in selectedStates) { | |
//pcData.push(stateMap[state]); | |
//to eliminate Total | |
pcData.push(stateMap[state].slice(0,stateMap[state].length-1)); | |
} | |
pcChart | |
.attr("normalize", true) | |
.attr("data", pcData) | |
.attr("height", 200) | |
.update(); | |
} | |
}); | |
map.addListener("deselectState", pcChart, function (chartEvent) { | |
console.log("UNSELECTED: " + chartEvent.state); | |
console.dir(selectedStates) | |
delete selectedStates[chartEvent.state]; | |
d3.selectAll("#ParChart").remove(); | |
var pcData = [] | |
for (var state in selectedStates) { | |
pcData.push(stateMap[state]); | |
} | |
pcChart | |
.attr("normalize", pcData.length <= 1) | |
.attr("data", pcData) | |
.attr("height", 200) | |
.update(); | |
}); | |
pcChart.render(); | |
map.render(); | |
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//thanks http://dexvis.com/vis/blog/2013/mar/reusable6/html/ParallelCoordinates3.html and http://syntagmatic.github.com/parallel-coordinates/ | |
ParallelCoordinates.prototype = new DexComponent(); | |
ParallelCoordinates.constructor = ParallelCoordinates; | |
function ParallelCoordinates(userConfig) | |
{ | |
DexComponent.call(this, userConfig, | |
{ | |
'id' : "ParallelCoordinates", | |
'class' : "ParallelCoordinates", | |
'parent' : null, | |
'height' : 400, | |
'width' : 600, | |
'opacity' : 100, | |
'strokeWidth' : 4, | |
'axisFontSize' : 16, | |
'fontSize' : 12, | |
'color' : d3.scale.category20(), | |
'title' : '', | |
'columnNames' : [ "X", "Y" ], | |
'data' : [[0,0],[1,1],[2,4],[3,9],[4,16]], | |
'rows' : 0, | |
'columns' : [], | |
'xoffset' : 0, | |
'yoffset' : 0, | |
'normalize' : false, | |
'axisLabels' : | |
{ | |
'stagger' : false, | |
'yoffset' : -9, | |
'staggeredYOffset' : -18 | |
} | |
}); | |
// Ugly, but my JavaScript is weak. When in handler functions | |
// this seems to be the only way to get linked back to the | |
// this.x variables. | |
this.chart = this; | |
} | |
ParallelCoordinates.prototype.render = function() | |
{ | |
this.update(); | |
}; | |
ParallelCoordinates.prototype.update = function () { | |
// If we need to call super: | |
//DexComponent.prototype.update.call(this); | |
var chart = this.chart; | |
var config = this.config; | |
var numericColumns = | |
dex.csv.getNumericColumnNames(config.columnNames, config.data); | |
var jsonData = dex.csv.toJson(config.columnNames, config.data); | |
var x = d3.scale.ordinal() | |
.rangePoints([0, config.width], 1); | |
var y = {}; | |
var line = d3.svg.line(); | |
var axis = d3.svg.axis().orient("left"); | |
var background; | |
var foreground; | |
var chartContainer = config.parent.append("g") | |
.attr("id", config["id"]) | |
.attr("class", config["class"]) | |
.attr("transform", | |
"translate(" + config.xoffset + "," + config.yoffset + ")"); | |
// Extract the list of dimensions and create a scale for each. | |
//x.domain(dimensions = d3.keys(cars[0]).filter(function(d) | |
//{ | |
// return d != "name" && (y[d] = d3.scale.linear() | |
// .domain(d3.extent(cars, function(p) { return +p[d]; })) | |
// .range([height, 0])); | |
//})); | |
var allExtents = [] | |
numericColumns.forEach(function (d) { | |
allExtents = allExtents.concat(d3.extent(jsonData, function (p) { return +p[d]; })); | |
}); | |
var normalizedExtent = d3.extent(allExtents); | |
//console.log("NE: " + normalizedExtent); | |
// REM: Figure out how to switch over to consistent extends. Snapping. | |
x.domain(dimensions = d3.keys(jsonData[0]).filter(function (d) { | |
if (d === "name") return false; | |
if (contains(numericColumns, d)) { | |
var extent = d3.extent(jsonData, function (p) { return +p[d]; }); | |
if (config.normalize) { | |
extent = normalizedExtent; | |
} | |
y[d] = d3.scale.linear() | |
.domain(extent) | |
.range([config.height, 0]); | |
allExtents.concat(extent); | |
} | |
else { | |
y[d] = d3.scale.ordinal() | |
.domain(jsonData.map(function (p) { return p[d]; })) | |
.rangePoints([config.height, 0]); | |
} | |
return true; | |
})); | |
// Add grey background lines for context. | |
background = chartContainer.append("g") | |
.attr("class", "background") | |
.selectAll("path") | |
.data(jsonData) | |
.enter().append("path") | |
.attr("d", path) | |
.attr("id", "fillpath"); | |
foreground = chartContainer.append("g") | |
.attr("fill", "none") | |
.attr("stroke-opacity", config.opacity / 100.0) | |
.selectAll("path") | |
.data(jsonData) | |
.enter().append("path") | |
.attr("d", path) | |
.attr("stroke", function (d, i) { return config.color(i); }) | |
.attr("stroke-width", config.strokeWidth) | |
.attr("title", function (d, i) { | |
var info = "<table border=\"1\">"; | |
for (var key in jsonData[i]) { | |
info += "<tr><td><b><i>" + key + "</i></b></td><td>" + jsonData[i][key] + "</td></tr>" | |
} | |
return info + "</table>"; | |
}) | |
.on("mouseover", function () { | |
d3.select(this) | |
.style("stroke-width", config.strokeWidth + (config.strokeWidth / 3)) | |
.style("stroke-opacity", config.opacity / 100.0); | |
}) | |
.on("mouseout", function () { | |
d3.select(this) | |
.style("stroke-width", config.strokeWidth) | |
.style("stroke-opacity", config.opacity / 100); | |
}); | |
// Original random colors: | |
// .attr("stroke", function(d) { return '#'+Math.floor(Math.random()*16777215).toString(16); }); | |
// Add a group element for each dimension. | |
var g = chartContainer.selectAll(".dimension") | |
.data(dimensions) | |
.enter().append("g") | |
.attr("font-size", config.fontSize) | |
.attr("class", "dimension") | |
.attr("transform", function (d) { return "translate(" + x(d) + ")"; }); | |
// Add an axis and title. | |
g.append("g") | |
.attr("class", "axis") | |
.each(function (d) { d3.select(this).call(axis.scale(y[d])); }) | |
.append("text") | |
.attr("text-anchor", "middle") | |
.attr("y", function (d, i) { | |
if (config.axisLabels.stagger) { | |
if (i % 2 == 1) { | |
return config.axisLabels.staggeredYOffset; | |
} | |
} | |
return config.axisLabels.yoffset; | |
}) | |
.attr("font-size", config.axisFontSize) | |
.text(String); | |
// Add and store a brush for each axis. | |
g.append("g") | |
.attr("class", "brush") | |
.each(function (d) { d3.select(this).call(y[d].brush = d3.svg.brush().y(y[d]).on("brush", brush)); }) | |
.selectAll("rect") | |
.attr("x", -8) | |
.attr("width", 16); | |
// Returns the path for a given data point. | |
function path(d) { | |
return line(dimensions.map(function (p) { return [x(p), y[p](d[p])]; })); | |
} | |
// Handles a brush event, toggling the display of foreground lines. | |
function brush() { | |
var actives = dimensions.filter(function (p) { return !y[p].brush.empty(); }), | |
extents = actives.map(function (p) { return y[p].brush.extent(); }); | |
foreground.style("display", function (d) { | |
return actives.every( | |
function (p, i) { | |
var displayYesOrNo; | |
// Categorical | |
if (!contains(numericColumns, p)) { | |
displayYesOrNo = extents[i][0] <= y[p](d[p]) && y[p](d[p]) <= extents[i][1]; | |
} | |
// Numeric | |
else { | |
displayYesOrNo = extents[i][0] <= d[p] && d[p] <= extents[i][1]; | |
} | |
//probably not the best place for it but loop through all the states and change the color to green if selected | |
allstates = d3.select("#StateMap").selectAll("path") | |
allstates.data().forEach(function (dd, ii) { | |
dd.id == d.State ? d3.select(allstates[0][ii]).attr("opacity", displayYesOrNo ? 1 : 0.3) : null | |
}); | |
return displayYesOrNo; | |
}) ? null : "none"; | |
}); | |
actives.length == 0 ? d3.select("#StateMap").selectAll("path").attr("opacity",1) : null; | |
} | |
}; | |
function contains(a, obj) | |
{ | |
var i = a.length; | |
while (i--) | |
{ | |
if (a[i] === obj) | |
{ | |
return true; | |
} | |
} | |
return false; | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
topojson=function(){function t(t,e){function n(e){var n=t.arcs[e],r=n[0],o=[0,0];return n.forEach(function(t){o[0]+=t[0],o[1]+=t[1]}),[r,o]}var r={},o={},a={};e.forEach(function(t){var e=n(t);(r[e[0]]||(r[e[0]]=[])).push(t),(r[e[1]]||(r[e[1]]=[])).push(~t)}),e.forEach(function(t){var e,r,i=n(t),c=i[0],s=i[1];if(e=a[c])if(delete a[e.end],e.push(t),e.end=s,r=o[s]){delete o[r.start];var u=r===e?e:e.concat(r);o[u.start=e.start]=a[u.end=r.end]=u}else if(r=a[s]){delete o[r.start],delete a[r.end];var u=e.concat(r.map(function(t){return~t}).reverse());o[u.start=e.start]=a[u.end=r.start]=u}else o[e.start]=a[e.end]=e;else if(e=o[s])if(delete o[e.start],e.unshift(t),e.start=c,r=a[c]){delete a[r.end];var f=r===e?e:r.concat(e);o[f.start=r.start]=a[f.end=e.end]=f}else if(r=o[c]){delete o[r.start],delete a[r.end];var f=r.map(function(t){return~t}).reverse().concat(e);o[f.start=r.end]=a[f.end=e.end]=f}else o[e.start]=a[e.end]=e;else if(e=o[c])if(delete o[e.start],e.unshift(~t),e.start=s,r=a[s]){delete a[r.end];var f=r===e?e:r.concat(e);o[f.start=r.start]=a[f.end=e.end]=f}else if(r=o[s]){delete o[r.start],delete a[r.end];var f=r.map(function(t){return~t}).reverse().concat(e);o[f.start=r.end]=a[f.end=e.end]=f}else o[e.start]=a[e.end]=e;else if(e=a[s])if(delete a[e.end],e.push(~t),e.end=c,r=a[c]){delete o[r.start];var u=r===e?e:e.concat(r);o[u.start=e.start]=a[u.end=r.end]=u}else if(r=o[c]){delete o[r.start],delete a[r.end];var u=e.concat(r.map(function(t){return~t}).reverse());o[u.start=e.start]=a[u.end=r.start]=u}else o[e.start]=a[e.end]=e;else e=[t],o[e.start=c]=a[e.end=s]=e});var i=[];for(var c in a)i.push(a[c]);return i}function e(e,r,o){function a(t){0>t&&(t=~t),(l[t]||(l[t]=[])).push(f)}function i(t){t.forEach(a)}function c(t){t.forEach(i)}function s(t){"GeometryCollection"===t.type?t.geometries.forEach(s):t.type in d&&(f=t,d[t.type](t.arcs))}var u=[];if(arguments.length>1){var f,l=[],d={LineString:i,MultiLineString:c,Polygon:c,MultiPolygon:function(t){t.forEach(c)}};s(r),l.forEach(3>arguments.length?function(t,e){u.push([e])}:function(t,e){o(t[0],t[t.length-1])&&u.push([e])})}else for(var p=0,h=e.arcs.length;h>p;++p)u.push([p]);return n(e,{type:"MultiLineString",arcs:t(e,u)})}function n(t,e){function n(t,e){e.length&&e.pop();for(var n,o=h[0>t?~t:t],a=0,i=o.length,c=0,s=0;i>a;++a)e.push([(c+=(n=o[a])[0])*f+d,(s+=n[1])*l+p]);0>t&&r(e,i)}function o(t){return[t[0]*f+d,t[1]*l+p]}function a(t){for(var e=[],r=0,o=t.length;o>r;++r)n(t[r],e);return 2>e.length&&e.push(e[0]),e}function i(t){for(var e=a(t);4>e.length;)e.push(e[0]);return e}function c(t){return t.map(i)}function s(t){var e=t.type,n="GeometryCollection"===e?{type:e,geometries:t.geometries.map(s)}:e in v?{type:e,coordinates:v[e](t)}:{type:null};return"id"in t&&(n.id=t.id),"properties"in t&&(n.properties=t.properties),n}var u=t.transform,f=u.scale[0],l=u.scale[1],d=u.translate[0],p=u.translate[1],h=t.arcs,v={Point:function(t){return o(t.coordinates)},MultiPoint:function(t){return t.coordinates.map(o)},LineString:function(t){return a(t.arcs)},MultiLineString:function(t){return t.arcs.map(a)},Polygon:function(t){return c(t.arcs)},MultiPolygon:function(t){return t.arcs.map(c)}};return s(e)}function r(t,e){for(var n,r=t.length,o=r-e;--r>o;)n=t[o],t[o++]=t[r],t[r]=n}function o(t,e){for(var n=0,r=t.length;r>n;){var o=n+r>>>1;e>t[o]?n=o+1:r=o}return n}function a(t){function e(t,e){t.forEach(function(t){0>t&&(t=~t);var n=a[t]||(a[t]=[]);n[e]||(n.forEach(function(t){var n,r;r=o(n=i[e],t),n[r]!==t&&n.splice(r,0,t),r=o(n=i[t],e),n[r]!==e&&n.splice(r,0,e)}),n[e]=e)})}function n(t,n){t.forEach(function(t){e(t,n)})}function r(t,e){"GeometryCollection"===t.type?t.geometries.forEach(function(t){r(t,e)}):t.type in c&&c[t.type](t.arcs,e)}var a=[],i=t.map(function(){return[]}),c={LineString:e,MultiLineString:n,Polygon:n,MultiPolygon:function(t,e){t.forEach(function(t){n(t,e)})}};return t.forEach(r),i}return{version:"0.0.32",mesh:e,object:n,neighbors:a}}(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//http://dexvis.com/vis/blog/2013/mar/reusable6/html/ParallelCoordinates3.html | |
USStateMap.prototype = new DexComponent(); | |
USStateMap.constructor = USStateMap; | |
function USStateMap(userConfig) | |
{ | |
DexComponent.call(this, userConfig, | |
{ | |
'parent' : null, | |
'id' : 'USStateMap', | |
'class' : 'USStateMap', | |
'labels' : [ "X", "Y" ], | |
'width' : 600, | |
'height' : 400, | |
'xoffset' : 0, | |
'yoffset' : 0, | |
"selectedColor" : "steelblue", | |
"unselectedColor" : "grey", | |
'topology' : {"type":"Topology","transform":{"scale":[0.010483693461690662,0.005244681944955843],"translate":[-171.79111060289114,18.91619]},"objects":{"states":{"type":"GeometryCollection","geometries":[{"type":"Polygon","id":"Maryland","arcs":[[0,1,2,3,4,5,6,7,8,9]]},{"type":"Polygon","id":"Minnesota","arcs":[[10,11,12,13,14]]},{"type":"Polygon","id":"Montana","arcs":[[15,16,17,18,19]]},{"type":"Polygon","id":"North Dakota","arcs":[[20,-18,21,-13]]},{"type":"MultiPolygon","id":"Hawaii","arcs":[[[22]],[[23]],[[24]],[[25]],[[26]]]},{"type":"Polygon","id":"Idaho","arcs":[[27,28,29,30,31,32,-16,33]]},{"type":"Polygon","id":"Washington","arcs":[[34,35,-32]]},{"type":"Polygon","id":"Arizona","arcs":[[36,37,38,39,40]]},{"type":"Polygon","id":"California","arcs":[[-37,41,42,43]]},{"type":"Polygon","id":"Colorado","arcs":[[44,45,46,47,48,49]]},{"type":"Polygon","id":"Nevada","arcs":[[-44,50,-29,51,-38]]},{"type":"Polygon","id":"New Mexico","arcs":[[52,-46,53,54,55]]},{"type":"Polygon","id":"Oregon","arcs":[[-51,-43,56,-35,-31,57]]},{"type":"Polygon","id":"Wyoming","arcs":[[58,-34,-20,59,60,-48]]},{"type":"Polygon","id":"Arkansas","arcs":[[61,62,63,64,65,66]]},{"type":"Polygon","id":"Iowa","arcs":[[67,68,69,70,-11,71]]},{"type":"Polygon","id":"Kansas","arcs":[[72,-50,73,74,75,76]]},{"type":"Polygon","id":"Missouri","arcs":[[77,78,-66,79,80,81,-75,82,-69,83]]},{"type":"Polygon","id":"Nebraska","arcs":[[-83,-74,-49,-61,84,-70]]},{"type":"Polygon","id":"Oklahoma","arcs":[[85,-54,-45,-73,86,-80,-65]]},{"type":"Polygon","id":"South Dakota","arcs":[[-85,-60,-19,-21,-12,-71]]},{"type":"Polygon","id":"Louisiana","arcs":[[87,88,89,90,-63]]},{"type":"Polygon","id":"Texas","arcs":[[-91,91,-55,-86,-64]]},{"type":"Polygon","id":"Connecticut","arcs":[[92,93,94,95]]},{"type":"Polygon","id":"Massachusetts","arcs":[[96,-94,97,98,99,100]]},{"type":"Polygon","id":"New Hampshire","arcs":[[101,102,103,104,-100]]},{"type":"Polygon","id":"Rhode Island","arcs":[[-97,105,-95]]},{"type":"Polygon","id":"Vermont","arcs":[[-99,106,107,-102]]},{"type":"Polygon","id":"Alabama","arcs":[[108,109,110,111,112]]},{"type":"Polygon","id":"Florida","arcs":[[-109,113,114]]},{"type":"Polygon","id":"Georgia","arcs":[[-114,-113,115,116,117,118]]},{"type":"Polygon","id":"Mississippi","arcs":[[-62,119,-111,120,121]]},{"type":"Polygon","id":"South Carolina","arcs":[[-118,122,123]]},{"type":"Polygon","id":"Illinois","arcs":[[124,125,-84,-68,126,127]]},{"type":"Polygon","id":"Indiana","arcs":[[128,129,-125,130,131]]},{"type":"Polygon","id":"Kentucky","arcs":[[132,133,134,-78,-126,-130,135]]},{"type":"Polygon","id":"North Carolina","arcs":[[-123,-117,136,137,138]]},{"type":"Polygon","id":"Ohio","arcs":[[-136,-129,139,140,141,142]]},{"type":"Polygon","id":"Tennessee","arcs":[[143,-137,-116,-112,-120,-67,-79,-135]]},{"type":"Polygon","id":"Wisconsin","arcs":[[-127,-72,-15,144,145,146]]},{"type":"Polygon","id":"West Virginia","arcs":[[147,-8,148,-133,-143,149]]},{"type":"Polygon","id":"Delaware","arcs":[[-1,150,151,152]]},{"type":"Polygon","id":"New Jersey","arcs":[[-152,153,154,155]]},{"type":"Polygon","id":"New York","arcs":[[-98,-93,156,-155,157,158,-107]]},{"type":"Polygon","id":"Pennsylvania","arcs":[[-151,-10,-150,-142,159,-158,-154]]},{"type":"Polygon","id":"Maine","arcs":[[-104,160]]},{"type":"MultiPolygon","id":"Michigan","arcs":[[[-140,-132,161]],[[162,163]]]},{"type":"MultiPolygon","id":"Alaska","arcs":[[[164]],[[165]],[[166]],[[167]]]},{"type":"MultiPolygon","id":"Virginia","arcs":[[[-7,168,-5,169,-138,-144,-134,-149]],[[2,170]]]},{"type":"Polygon","id":"District of Columbia","arcs":[[-6,-169]]},{"type":"Polygon","id":"Utah","arcs":[[-52,-28,-59,171,-39]]}]}},"arcs":[[[9157,3967],[7,-243],[63,0]],[[9227,3724],[0,-9],[-31,-74]],[[9196,3641],[-22,-3],[-11,-12]],[[9163,3626],[-15,22],[-12,19],[-10,15],[-12,17],[-2,29],[-2,31],[-2,28],[-2,35],[-3,35],[-7,-32],[-5,-25],[-6,-25],[5,-31],[5,-32],[5,-28],[5,-30],[-12,6],[-13,6],[-17,8],[-21,10]],[[9042,3684],[-1,6],[-4,21],[-16,-9],[-12,11],[10,42],[13,14],[4,4],[1,16]],[[9037,3789],[3,3],[2,3],[3,4],[2,3],[3,4],[-3,4],[-2,4],[-3,4],[-2,4],[-2,3],[-3,-2],[-2,-3],[-3,-4]],[[9030,3816],[-18,22],[-20,11],[1,5],[6,16],[-13,14],[-11,5],[-3,1]],[[8972,3890],[-7,25],[-12,27],[-29,15],[-19,-14],[-10,-15],[-28,8],[-13,-20],[-19,-7],[-16,-22]],[[8819,3887],[-15,-17],[1,96]],[[8805,3966],[88,0],[31,0],[67,1],[82,-1],[84,1]],[[7684,4687],[-125,4],[-139,-2],[-130,-2],[-104,0]],[[7186,4687],[1,178],[-12,183],[-16,15],[-10,29],[5,26],[22,21],[1,28]],[[7177,5167],[1,35],[-6,29],[-8,30],[-5,39],[-1,44],[-3,10],[-4,56],[-1,26],[-2,22],[-4,39],[-12,39],[-11,35],[-2,35],[-1,37],[3,24],[1,23],[-9,27],[-1,19]],[[7112,5736],[197,0],[0,73],[33,1],[17,-105],[29,-32],[67,-12],[97,-30],[93,-59],[77,25],[117,-50],[-97,-63],[-68,-76],[-64,-81],[-1,-28]],[[7609,5299],[-25,-10],[1,-107],[-3,0],[-23,-21],[-21,-18],[-13,-36],[20,-35],[-8,-48],[0,-52],[-3,-42],[28,-36],[12,-2],[31,-27],[10,-13],[7,-21],[24,-32],[32,-29],[3,-15],[1,-46],[2,-22]],[[5790,4879],[-10,10],[-10,27],[-10,5],[-14,-38],[-21,-6],[-54,12],[-3,-19],[-31,7],[-18,-26],[-17,49],[-11,28],[-20,5],[-6,14],[-6,50],[-17,23],[-10,61],[-12,26],[-11,5],[-10,-27],[-19,-22],[-17,18],[-1,49],[11,13],[-8,49],[9,50],[11,42],[-29,2],[-24,27],[-27,59],[-16,30],[-22,18],[-18,30],[0,35],[-25,50],[-7,201]],[[5317,5736],[285,0],[285,0],[285,0],[285,1]],[[6457,5737],[1,-350],[5,-232]],[[6463,5155],[-5,-174]],[[6458,4981],[-159,2],[-171,-1],[-149,2],[-188,-2],[1,-97],[-2,-6]],[[7177,5167],[-181,-10],[-155,0],[-196,-1],[-182,-1]],[[6457,5737],[330,-1],[325,0]],[[1549,31],[-14,-31],[-23,27],[3,53],[-16,70],[4,21],[17,31],[-7,37],[6,18],[7,-3],[37,-33],[17,-16],[15,-26],[25,-67],[-3,-10],[-37,-41],[-31,-30]],[[1498,329],[-32,-14],[-16,40],[-11,16],[-1,12],[9,16],[34,-18],[25,-29],[-8,-23]],[[1433,431],[-3,-21],[-51,5],[7,24],[47,-8]],[[1348,458],[-5,-11],[-7,3],[-33,6],[-12,44],[-4,7],[26,27],[8,-13],[27,-63]],[[1187,584],[-12,-19],[-32,35],[5,14],[15,19],[22,-5],[2,-44]],[[5793,4401],[-284,-1]],[[5509,4400],[-286,1]],[[5223,4401],[1,343],[9,54]],[[5233,4798],[-8,25],[-18,12],[0,31],[14,43],[20,38],[14,61],[13,50],[10,24],[-6,29],[-16,16],[-22,37]],[[5234,5164],[1,33],[-9,30],[-3,265],[0,243]],[[5223,5735],[94,1]],[[5790,4879],[3,-4],[0,-474]],[[5234,5164],[-197,-2],[-34,-20],[-24,9],[-19,-16],[-35,-21],[-43,3],[-22,-16],[-20,-7],[-15,10],[-34,9],[-22,-6],[-37,-21],[-23,0],[-22,7],[-7,27],[-3,32],[-18,36],[-27,11],[-23,17],[-30,1],[-21,1]],[[4558,5218],[-7,110],[-31,164],[-27,88],[11,37],[138,-64],[51,-180],[23,50],[-15,156],[-32,157],[270,0],[284,-1]],[[5443,2632],[13,-1],[10,38],[-17,26],[-3,29],[-5,33],[19,44],[7,87],[29,39],[-18,37],[-12,36],[-8,33],[-5,26],[-2,17]],[[5451,3076],[6,38],[-5,37],[-2,37],[0,41],[-9,26],[7,24],[20,0],[18,-14],[13,-7],[7,29],[4,6],[-1,153]],[[5509,3446],[154,3],[183,0],[139,-1]],[[5985,3448],[0,-1079]],[[5985,2369],[-189,-2],[-218,135],[-144,92],[9,38]],[[5443,2632],[-121,-21],[-108,-15],[-16,98],[-62,109],[-45,23],[-10,55],[-54,9],[-34,52],[-88,19],[-25,31],[-11,104],[-93,192],[-79,265],[3,44],[-42,63],[-74,160],[-13,155],[-51,104],[21,158],[-3,164]],[[4538,4401],[402,-2]],[[4940,4399],[0,-571],[179,-258],[172,-252],[160,-242]],[[6653,3446],[-92,1]],[[6561,3447],[-114,0],[-162,0],[-151,0],[-149,0]],[[5985,3447],[-1,764]],[[5984,4211],[95,0],[96,0],[191,0],[96,0]],[[6462,4211],[190,0],[0,-185],[0,-6]],[[6652,4020],[1,-294],[0,-280]],[[4940,4399],[283,1],[0,1]],[[5509,4400],[0,-954]],[[5985,2369],[0,1078]],[[6561,3447],[0,-95]],[[6561,3352],[0,-499],[0,-359],[-88,0],[-172,0],[-86,0],[1,-16],[11,-31]],[[6227,2447],[-166,0],[0,-78],[-76,0]],[[4538,4401],[-31,146],[38,180],[23,346],[-10,145]],[[5233,4798],[-8,-54],[-2,-343]],[[5984,4211],[-35,0],[-39,2],[-40,1],[-43,1],[-34,1],[0,69],[0,64],[0,52]],[[6458,4981],[3,-389]],[[6461,4592],[1,-381]],[[7777,3070],[-1,-15],[-17,-14],[-1,-28],[-12,-51],[-11,-11],[-17,-26],[-10,-39],[-21,-66],[-2,-46],[11,-50],[-5,-37]],[[7691,2687],[-81,6],[-104,-6],[-92,0]],[[7414,2687],[6,108],[-23,1],[-18,-2],[-5,12]],[[7374,2806],[3,167],[2,185],[-19,202]],[[7360,3360],[116,-3],[105,0],[101,0],[109,-12],[7,-24],[-10,-20],[-11,-21],[-6,-19],[62,0]],[[7833,3261],[-1,-16],[-9,-26],[-17,-19],[-4,-32],[-15,-25],[1,-55],[-11,-18]],[[7740,4497],[6,-14],[11,-10],[4,-21],[15,-15],[10,-16],[-5,-52],[-17,-43],[-7,-14],[-22,-11],[-32,-9],[-9,-33],[12,-15],[4,-29],[-12,-33],[-7,-29],[-24,-28],[-2,-35]],[[7665,4090],[-13,16],[-18,31],[-105,-5],[-109,-1],[-86,0],[-86,0]],[[7248,4131],[-6,34],[3,34],[-2,33],[-10,55],[-6,23],[-7,6],[-1,44],[-6,32],[-17,36],[0,16],[-6,31],[-5,19]],[[7185,4494],[1,18],[-16,21],[8,31],[5,31],[2,20],[-12,26],[0,46],[13,0]],[[7684,4687],[1,-10],[13,-31],[-9,-14],[1,-40],[4,-17],[6,-30],[31,-19],[9,-29]],[[7277,3447],[-172,0],[-172,0],[-95,-1],[-96,0],[-89,0]],[[6652,4020],[167,0],[124,0],[219,0],[132,0]],[[7294,4020],[22,-26],[13,1],[2,-28],[-13,-35],[7,-18],[12,-40]],[[7337,3874],[25,-18],[-1,-205]],[[7361,3651],[-1,-203],[-83,-1]],[[7887,3438],[-3,-19],[2,-30],[-16,-16],[-21,-20]],[[7849,3353],[-2,-18],[-6,-27],[-8,-47]],[[7360,3360],[1,87],[-1,0]],[[7360,3447],[1,204]],[[7361,3651],[1,204],[-25,19]],[[7294,4020],[-13,41],[-15,24],[-16,30],[-2,16]],[[7665,4090],[-9,-48],[9,-57],[16,-39],[18,-32],[22,-26],[9,-9],[8,-36],[1,-32],[11,-8],[18,13],[18,-31],[-5,-35],[-9,-28],[-6,-34],[13,-28],[19,-27],[11,-1],[25,-42],[10,-5],[7,-46],[-4,-29],[13,-47],[10,5],[17,-30]],[[6461,4592],[186,0],[143,0],[191,0],[25,-24],[35,-16],[8,9],[23,-1],[34,2],[25,-24],[26,-16],[4,-16],[8,-9],[16,-3]],[[7374,2806],[-41,37],[-27,21],[-22,-13],[-33,2],[-20,0],[-16,-16],[-16,-8],[-14,9],[-32,-10],[-14,32],[-15,-28],[-26,13],[-27,29],[-29,-19],[-12,46],[-45,-4],[-28,10],[-32,13],[-14,40],[-25,-13],[-16,16],[-23,20],[0,182],[0,187],[-95,0],[-96,0],[-95,0]],[[7277,3447],[83,0]],[[7691,2687],[7,-11],[-9,-28],[14,-39],[-4,-24],[12,-32],[-13,-20],[-4,-36],[-19,-30],[-8,-40],[-9,-46],[-12,-21],[4,-47],[84,-7],[90,0],[-3,-32],[-6,-31],[6,-24],[13,-22],[3,-32]],[[7837,2165],[2,-19],[1,-3]],[[7840,2143],[17,-50],[-1,-78],[20,-37],[-18,-25],[-36,28],[-36,-36],[-69,5],[-71,101],[-83,-24],[-70,45],[-59,-14]],[[7434,2058],[-7,21],[10,28],[14,25],[1,38],[-7,13],[8,45],[6,21],[9,70],[-8,26],[-11,43],[-8,44],[-6,30],[-15,21],[-6,204]],[[7434,2058],[-80,-44],[-87,-142],[-95,-82],[-52,-91],[-22,-86],[-1,-131],[5,-92],[18,-65],[-37,-5],[-68,42],[-74,59],[-27,89],[-21,134],[-56,108],[-33,112],[-48,131],[-67,76],[-78,-4],[-60,-151],[-79,58],[-50,57],[-23,105],[-32,100],[-57,83],[-49,61],[-34,67]],[[9361,4202],[-1,5],[-3,24],[20,18],[-7,16],[5,146]],[[9375,4411],[73,-3],[89,-5]],[[9537,4403],[1,-104],[-6,-28]],[[9532,4271],[-42,-9],[-55,-10],[-74,-51],[0,1]],[[9602,4305],[-3,29],[-15,22],[-7,50],[-40,-3]],[[9375,4411],[21,132]],[[9396,4543],[79,-3]],[[9475,4540],[115,-2],[10,19],[20,12],[11,-3]],[[9631,4566],[-1,-101],[32,-101],[39,-5],[-10,70],[29,-43],[-8,-54],[-64,-31],[-46,4]],[[9475,4540],[-8,19],[7,25],[3,50],[3,12],[3,45],[10,38],[8,17],[12,45],[2,31],[3,18],[18,9],[22,22],[3,24],[-7,28],[12,51],[-1,0]],[[9565,4974],[10,47],[30,10]],[[9605,5031],[14,-351],[-4,-18],[18,-29],[4,-26],[10,2]],[[9647,4609],[-16,-43]],[[9602,4305],[-70,-34]],[[9396,4543],[4,157],[-14,1],[-1,8],[6,27],[-9,50],[9,39],[-5,30],[-2,56],[4,25],[2,38]],[[9390,4974],[175,0]],[[8278,2302],[-195,-1],[-54,-11],[-2,-15],[22,-46],[-5,-38],[-7,-26]],[[8037,2165],[-85,21]],[[7952,2186],[-3,291],[17,305],[17,247],[-7,37]],[[7976,3066],[120,0],[123,-2]],[[8219,3064],[24,-237],[23,-190],[13,-59],[9,-34],[-16,-34],[-5,-61],[5,-35],[-2,-34],[-3,-31],[6,-25],[5,-22]],[[8278,2302],[14,-52],[96,-8],[155,-29],[7,-33],[12,17],[0,66],[12,7],[19,-14],[20,-4]],[[8613,2252],[17,-132],[32,-164],[42,-134],[1,-83],[45,-221],[-3,-129],[-4,-74],[-24,-116],[-29,-24],[-47,23],[-15,83],[-36,44],[-51,164],[-44,146],[-14,75],[19,126],[-26,105],[-75,160],[-37,29],[-96,-87],[-17,10],[-47,89],[-59,47],[-108,-24]],[[8219,3064],[73,-2],[51,2]],[[8343,3064],[119,-2]],[[8462,3062],[-11,-16],[-15,-36],[26,-31],[16,-12],[18,-60],[11,-34],[34,-45],[6,-24],[23,-31],[11,-46],[30,-38],[7,-44],[6,-21],[-3,-14],[17,-21],[10,-35],[0,-37],[8,-7],[17,-9]],[[8673,2501],[-45,-114],[-15,-135]],[[7777,3070],[94,0],[105,-4]],[[7952,2186],[-73,-13],[-39,-30]],[[7840,2143],[-3,22],[-3,32],[-13,22],[-6,24],[6,31],[3,32],[-90,0],[-84,7],[-4,47],[12,21],[9,46],[8,40],[19,30],[4,36],[13,20],[-12,32],[4,24],[-14,39],[9,28],[-7,11]],[[8462,3062],[9,6],[52,33],[88,-2],[44,-9],[1,-17],[10,13],[15,-32],[-1,-23],[106,-2],[107,-180]],[[8893,2849],[-48,-70],[-14,-64],[-105,-124],[-53,-90]],[[8037,4345],[0,-221],[0,-220],[-11,-53],[8,-14],[5,-33],[-1,-26],[-8,-11],[-7,-32],[-19,-41],[-14,-52],[-3,-38]],[[7987,3604],[1,-14],[-11,-27],[8,-18],[-17,-14],[-21,-16],[4,-41],[-13,-16],[-23,17],[-25,11],[-7,-19],[4,-29]],[[7740,4497],[97,0],[100,0],[73,-2],[0,1],[1,0]],[[8011,4496],[0,-1],[0,-49],[26,-101]],[[8297,4339],[-1,-172],[0,-186],[-1,-132]],[[8295,3849],[-6,-9],[8,-39],[-4,-14],[-16,0],[-15,-17],[-22,7],[-2,-37],[-14,-14],[-12,-33],[-14,-5],[-21,-57],[-19,16],[-6,23],[-17,-38],[-10,-21],[-21,23],[-22,-18],[-7,-19],[-30,29],[-20,-21],[-25,15],[0,-21],[-13,5]],[[8037,4345],[9,-13],[32,1],[26,21]],[[8104,4354],[103,-1],[90,1],[0,-15]],[[8508,3717],[2,-18],[-1,-39],[11,-30],[5,-29],[14,-25],[9,-23],[19,-3]],[[8567,3550],[-10,-15],[-28,-42],[-30,-22],[-2,-16],[-10,-20],[-25,-21],[-2,-2],[-1,-2],[-7,-16],[-15,-9],[-5,-3],[-27,-11]],[[8405,3371],[-65,-6],[-84,8],[-27,-2],[-55,5],[-56,2],[-51,1],[-60,-6],[-3,9],[-19,0],[0,-30],[-136,1]],[[8295,3849],[33,-4],[17,-19],[25,-43],[20,-13],[15,-16],[22,6],[17,-11],[21,10],[18,3],[7,-26],[18,-19]],[[8343,3064],[2,40],[20,12],[7,21],[13,23],[20,5],[22,8],[22,17],[9,17],[19,15],[-1,14],[24,26],[8,-17],[35,36],[16,-4],[15,32],[20,8],[-2,28],[3,24]],[[8595,3369],[161,-9],[190,-1],[101,2],[90,1],[12,0]],[[9149,3362],[14,-191],[-61,-141],[-99,-57],[-62,-112],[-48,-12]],[[8297,4339],[48,2],[44,0],[36,2]],[[8425,4343],[59,-40],[47,-10],[69,26],[57,52],[49,26]],[[8706,4397],[0,-255]],[[8706,4142],[-14,-10],[4,-24],[-4,-44],[-10,-50],[-9,-41],[-2,-19],[-26,-44],[-11,-9],[-13,-6],[-11,5],[-21,-33],[-4,-34],[-3,-19],[-9,-8],[-1,22],[-13,4],[-13,-41],[-2,-42],[-12,-27],[-24,-5]],[[8405,3371],[142,-6],[11,1],[37,3]],[[7609,5299],[96,40],[58,-65]],[[7763,5274],[0,-1],[6,4],[15,-7],[8,-34],[84,-34],[55,-34],[27,-1],[18,-2],[5,-31],[23,-12],[8,-27],[-5,-15],[-5,-31],[21,-2],[-7,-31],[13,-22],[2,-1]],[[8031,4993],[0,-2],[-38,-69],[13,-23],[70,123],[15,1],[-50,-147],[-22,-133],[-18,-108],[12,-93],[-2,-46]],[[8805,3966],[-1,-97],[15,18]],[[8972,3890],[-10,-35],[-5,4],[-44,47],[-2,-11],[-6,-40],[-8,-13],[-3,-6],[-8,-10],[-11,-14],[-14,-25],[-7,8],[-4,-10],[-7,-17],[-9,-24],[-5,-17],[-13,-8],[-15,14],[-12,15],[-9,-42],[-8,-15],[-9,-19],[-4,-28],[-19,-25],[-13,-33],[2,-22],[-1,-7],[-1,-11],[-15,-14],[-14,2],[-12,-13],[-10,6],[-1,-6],[-1,-11],[-6,-2],[-30,-14],[-11,14],[-9,-6],[-22,-17],[-14,15],[-2,4],[-9,13],[-4,33]],[[8706,4142],[0,-176],[99,0]],[[9157,3967],[7,15],[9,8],[20,-9]],[[9193,3981],[-14,-20],[3,-37]],[[9182,3924],[20,-103],[23,-34],[2,-63]],[[9193,3981],[20,17],[7,12],[22,25],[13,21],[-30,49],[-2,20],[-10,6],[0,31],[11,23],[-5,25],[15,17],[17,43],[12,8]],[[9263,4278],[73,-75],[-4,-40]],[[9332,4163],[-29,-53],[28,-9],[-21,-137],[-69,-147],[-7,49],[-21,10],[-31,48]],[[9361,4202],[-6,-5],[140,36],[28,-36],[-133,-57],[-61,-1],[3,24]],[[9263,4278],[-16,14],[-16,13],[-6,27],[2,21],[-11,18],[-21,30],[-129,0],[-139,0],[-149,0],[0,52]],[[8778,4453],[82,113],[-2,19],[-8,57],[45,22],[75,-7],[78,-16],[71,63],[-5,74],[-10,27],[98,133],[43,35],[145,1]],[[8706,4397],[72,55],[0,1]],[[9605,5031],[41,30],[34,86],[29,149],[73,144],[31,-51],[64,33],[43,-55],[0,-260],[62,-108],[17,-62],[-102,-93],[-98,-66],[-101,-56],[-51,-113]],[[8104,4354],[19,27],[39,93],[3,125],[-32,118],[5,81],[25,94],[24,64],[38,45],[9,-63],[16,94],[22,19],[13,73],[81,-39],[71,-74],[7,-87],[-8,-86],[-53,-77],[5,-48],[19,-1],[59,84],[35,-20],[18,-110],[4,-78],[-45,-105],[-20,-67],[-33,-73]],[[8031,4993],[-2,1],[-13,22],[7,31],[-21,2],[5,31],[5,15],[-8,27],[-23,12],[-5,31],[-18,2],[-27,1],[-55,34],[-84,34],[-8,34],[-15,7],[-6,-4],[0,1],[0,-1]],[[7763,5273],[74,49],[77,62],[84,63],[-31,-101],[54,-24],[67,-73],[85,43],[94,16],[20,-53],[29,-8],[6,19],[-6,-19],[25,-6],[48,-76],[-84,-17],[-3,1],[-75,20],[-75,-38],[-65,-17],[-56,-121]],[[1791,7283],[-95,-73],[-49,50],[-14,89],[86,68],[51,29],[63,-13],[41,-59],[-83,-91]],[[592,7816],[-58,-30],[-63,36],[-58,52],[94,32],[76,-17],[9,-73]],[[5,8554],[59,-36],[60,19],[77,-50],[94,-25],[-8,-21],[-72,-40],[-72,41],[-37,35],[-84,-11],[-22,16],[5,72]],[[1595,9958],[69,-86],[42,37],[161,-11],[-5,-44],[145,-32],[98,19],[201,-61],[183,-18],[74,-24],[127,31],[144,-58],[104,-26],[-1,-708],[0,-1086],[94,-5],[93,-53],[66,-84],[85,-125],[93,107],[95,61],[51,-98],[64,-78],[88,-86],[59,-137],[98,-217],[162,-122],[3,-120],[-53,-92],[-53,72],[-84,60],[-27,167],[-123,154],[-51,180],[-92,12],[-151,5],[-112,55],[-197,198],[-92,36],[-167,68],[-132,-16],[-187,87],[-114,82],[-106,-41],[20,-132],[-53,-12],[-110,-40],[-84,-65],[-106,-40],[-13,112],[43,187],[101,59],[-26,48],[-122,-106],[-65,-127],[-137,-136],[69,-93],[-90,-137],[-102,-79],[-96,-58],[-23,-85],[-149,-98],[-30,-90],[-112,-81],[-65,14],[-89,-53],[-97,-65],[-80,-64],[-163,-54],[-15,32],[104,89],[93,59],[102,104],[118,22],[47,78],[133,114],[21,38],[70,68],[17,144],[48,113],[-110,-58],[-30,33],[-52,-70],[-62,97],[-26,-68],[-36,95],[-95,-77],[-59,1],[-8,113],[17,70],[-61,68],[-124,-37],[-81,90],[-65,46],[0,108],[-74,81],[37,110],[78,106],[34,98],[77,14],[66,-31],[77,92],[69,-16],[73,59],[-18,87],[-54,34],[71,74],[-59,-2],[-101,-42],[-29,-42],[-75,42],[-135,-21],[-140,46],[-40,76],[-120,111],[134,80],[212,93],[79,0],[-13,-95],[201,7],[-77,118],[-118,73],[-67,95],[-92,81],[-131,61],[53,100],[170,6],[120,87],[23,93],[97,90],[93,22],[181,85],[88,-13],[146,102],[145,-41]],[[9030,3816],[3,-6],[2,-5],[3,-5],[0,-5],[-1,-6]],[[9042,3684],[66,-61],[4,-182],[27,-13],[10,-66]],[[9163,3626],[-29,-130],[8,-7],[54,152]],[[5984,4211],[1,-763]]]} | |
}); | |
// Ugly, but my JavaScript is weak. When in handler functions | |
// this seems to be the only way to get linked back to the | |
// this.x variables. | |
this.chart = this; | |
} | |
USStateMap.prototype.render = function() | |
{ | |
this.update(); | |
}; | |
USStateMap.prototype.update = function() | |
{ | |
// If we need to call super: | |
//DexComponent.prototype.update.call(this); | |
var chart = this.chart; | |
var config = this.config; | |
var selected = {}; | |
var path = d3.geo.path(); | |
var chartContainer = config.parent.append("g") | |
.attr("id", config["id"]) | |
.attr("class", config["class"]) | |
.attr("transform", "translate(" + config.xoffset + "," + config.yoffset + ")") | |
.attr("width", config.width) | |
.attr("height", config.height); | |
chartContainer.selectAll("path") | |
.data(topojson.object(config.topology, config.topology.objects.states).geometries) | |
.enter().append("path") | |
.attr("d", path) | |
.style("fill", config.unselectedColor) | |
.on("mouseover", function(d) | |
{ | |
chart.notify({ type: "mouseover", state : d.id }); | |
}) | |
.on("mousedown", function(d) | |
{ | |
if (selected[d.id] == null) | |
{ | |
chart.notify({ type: "selectState", state : d.id }); | |
selected[d.id] = true; | |
d3.select(this).style("fill", config.selectedColor); | |
} | |
else | |
{ | |
console.log("unsel"); | |
chart.notify({ type: "deselectState", state : d.id }); | |
selected[d.id] = null; | |
d3.select(this).style("fill", config.unselectedColor); | |
} | |
}); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
VerticalLegend.prototype = new DexComponent(); | |
VerticalLegend.constructor = VerticalLegend; | |
function VerticalLegend(userConfig) | |
{ | |
DexComponent.call(this, userConfig, | |
{ | |
'labels' : [ "A", "B", "C" ], | |
'id' : "VerticalLegend", | |
'class' : "VerticalLegend", | |
'parent' : null, | |
'xoffset' : 50, | |
'yoffset' : 30, | |
'cellWidth' : 30, | |
'cellHeight' : 20, | |
'tickLength' : 5, | |
'caption' : "Legend", | |
'color' : d3.scale.category20c(), | |
'captionFontSize' : 14, | |
'captionXOffset' : -30, | |
'captionYOffset' : -20, | |
}); | |
// Ugly, but my JavaScript is weak. When in handler functions | |
// this seems to be the only way to get linked back to the | |
// this.x variables. | |
this.chart = this; | |
} | |
VerticalLegend.prototype.render = function() | |
{ | |
this.update(); | |
}; | |
VerticalLegend.prototype.update = function() | |
{ | |
// If we need to call super: | |
//DexComponent.prototype.update.call(this); | |
var chart = this.chart; | |
var config = this.config; | |
// Create our x scale | |
var y = d3.scale.ordinal() | |
.domain(config.labels) | |
.range(d3.range(config.labels.length).map(function(i) { return i * config.cellHeight; })); | |
// Create the x axis. | |
var yAxis = d3.svg.axis() | |
.scale(y) | |
.orient("left") | |
.tickSize(config.tickLength) | |
.tickPadding(10) | |
.tickValues(config.labels) | |
.tickFormat(function(d) { return d; }); | |
// Append a graphics node to the supplied svg node. | |
var chartContainer = config.parent.append("g") | |
.attr("id", config["id"]) | |
.attr("class", config["class"]) | |
.attr("transform", | |
"translate(" + config.xoffset + "," + config.yoffset + ")"); | |
// Draw a colored rectangle for each ordinal range. | |
chartContainer.selectAll("rect") | |
.data(config.labels) | |
.enter().append("rect") | |
.attr("height", config.cellHeight) | |
.attr("y", function(d, i) { return y(i); }) | |
.attr("width", config.cellWidth) | |
.style("fill", function(d, i) | |
{ | |
return config.color(i); | |
}); | |
// Add the caption. | |
chartContainer.call(yAxis).append("text") | |
.attr("class", "caption") | |
.attr("y", config.captionYOffset) | |
.attr("x", config.captionXOffset) | |
.text(config.caption) | |
.style("font-size", config.captionFontSize); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment