<!DOCTYPE html>
<meta charset="utf-8">
<style>
path {
fill: #ccc;
stroke: #fff;
stroke-width: .5px;
}
path:hover {
fill: red;
}
<link href="nv.d3.css" rel="stylesheet" type="text/css">
</style>
<body>
<script src="//d3js.org/d3.v2.js"></script>
<script src="//d3js.org/topojson.v0.min.js"></script>
<script src="DexUtils.js"></script>
<script src="DexComponent.js"></script>
<script src="VerticalLegend.js"></script>
<script src="BarChart.js"></script>
<script src="USStateMap.js"></script>
<script src="nv.d3.js"/></script>
<script src="src/utils.js"></script>
<script src="src/tooltip.js"></script>
<script src="src/models/legend.js"></script>
<script src="src/models/axis.js"></script>
<script src="src/models/multiBarHorizontal.js"></script>
<script src="src/models/multiBarHorizontalChart.js"></script>
<script src="stream_layers.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", 800)
.append("g")
.attr("transform", "translate(40,20)");
// Configure a chart.
var map = new USStateMap(
{
'parent': svg,
'xoffset': 200
}
);
var labels = [
"State", "Property Tax", "Sales Tax", "Alcohol", "Amusement", "Insurance", "Gas", "Pari-Mutuels", "Utilities",
"Tobacco", "Other Sales", "Alcoholic Lic", "Amusement Lic", "Corp Lic", "Hunt/Fish Lic", "Vehicle Lic", "Drivers Lic", "Util Lic",
"Occ/Biz Lic", "Other Lic", "Income Tax", "Corp Net Inc Tax", "Death/Gift Tax",
"Doc/Stock Txfer Tax", "Severance Taxes", "Other Taxes", "Total Taxes"];
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]
];
stateMap = dex.csv.createRowMap(labels, stateData, 0);
//now get totals for each type of tax
var taxTotals = [];
labels.slice(1, labels.length - 1).forEach(function (d, i) { taxTotals.push(d3.sum(stateData, function (dd) { return dd[i] })) })
//get the data from dexvis in format similar to the nvd3 example
//this is an intermediate step to get structure
//key: State
//values: array
stateNest = d3.nest()
.key(function (d) { return d[0]; })
.rollup(function (d) { return d; })
.entries(stateData);
//now get the values in proper structure
//label : labels[i] from labels array
//value : amount of taxes
//eliminate State Name at 0 and Total at last
stateNest.forEach(function (d) {
var oldvalues = d.values[0].slice(1, d.values[0].length - 1);
oldvalues.forEach(function (dd, ii) { d.values[ii] = { "label": labels[ii + 1], "value": dd, "pcttotal": dd / d3.sum(oldvalues) - taxTotals[ii + 1] / d3.sum(taxTotals) }; })
})
//end of replacement
var barChart = new BarChart(
{
'parent': svg,
'height': 200,
'width': 900,
'id': "StateStatisticsBarChart",
'yaxisLabel': "",
'labels': labels,
'data': [],
'xi': 0,
'yi': d3.range(26).map(function (i) { return i + 1; }),
'yaxisLabelFontSize': 18,
'yaxisLabel': 'Taxes',
'yaxisFormat': ",d",
'xoffset': 220,
'yoffset': 500
}
);
//---------------------------------------------------------
var chart;
nv.addGraph(function () {
chart = nv.models.multiBarHorizontalChart()
.x(function (d) { return d.label })
.y(function (d) { return d.value })
.margin({ top: 30, right: 20, bottom: 50, left: 175 })
.height(500)
.width(400)
.showValues(true)
//.tooltips(true)
//.barColor(d3.scale.category20().range())
.showControls(false)
.showLegend(false)
.stacked(true);
chart.yAxis
.tickFormat(d3.format(',.2f'));
d3.select('svg').append('g')
.datum(stateNest)
.attr("class", "horizontalbar")
.transition().duration(500)
.call(chart);
nv.utils.windowResize(chart.update);
chart.dispatch.on('stateChange', function (e) { nv.log('New State:', JSON.stringify(e)); });
return chart;
});
//------------------------------------------------------------
map.addListener("click", barChart, function (chartEvent) {
if (stateMap[chartEvent.state] != null) {
d3.selectAll("#StateStatisticsBarChart").remove();
var bcData = [stateMap[chartEvent.state]];
barChart.attr("data", bcData)
barChart.update();
d3.selectAll('.horizontalbar').remove();
nv.addGraph(function () {
chart = nv.models.multiBarHorizontalChart()
.x(function (d) { return d.label })
.y(function (d) { return d.pcttotal })
.margin({ top: 30, right: 20, bottom: 50, left: 175 })
.height(500)
.width(400)
//.showValues(true)
//.tooltips(true)
.barColor(d3.scale.category20())
.showControls(false)
.showLegend(false)
.stacked(false);
chart.yAxis
.tickFormat(d3.format(',.2f'));
d3.select('svg').append('g')
.datum(stateNest.filter(function (d) { return d.key == chartEvent.state }))
.attr("class", "horizontalbar")
.transition().duration(500)
.call(chart);
nv.utils.windowResize(chart.update);
chart.dispatch.on('stateChange', function (e) { nv.log('New State:', JSON.stringify(e)); });
return chart;
});
}
});
var legend = new VerticalLegend(
{
parent: svg,
labels: labels.slice(1),
caption: "",
xoffset: 120,
yoffset: 0,
cellHeight: 25
});
barChart.render();
map.render();
</script>
BarChart.prototype = new DexComponent();
BarChart.constructor = BarChart;
function BarChart(userConfig)
{
DexComponent.call(this, userConfig,
{
parent : null,
labels : [ "X", "Y" ],
id : "BarChart",
data : [[0,0],[1,1],[2,4],[3,9],[4,16]],
width : 600,
height : 400,
xi : 0,
yi : [1],
xoffset : 0,
yoffset : 0,
barColors : d3.scale.category20(),
yaxisLabel : "Y",
yaxisLabelFontSize : 10,
xaxisLabel : "X",
xaxisLabelFontSize : 10,
yaxisFormat : ".f",
xmin : null,
ymin : null
});
// 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;
}
BarChart.prototype.render = function()
{
this.update();
};
BarChart.prototype.update = function()
{
// If we need to call super:
//DexComponent.prototype.update.call(this);
var chart = this.chart;
var config = this.config;
var yaxisFormat = d3.format(config.yaxisFormat);
// X domain across groups.
var x = d3.scale.ordinal()
.domain(d3.range(config.data.length))
.rangeBands([0, config.width], .1);
// X domain within groups.
var x1 = d3.scale.ordinal()
.domain(d3.range(config.yi.length))
.rangeBands([0, x.rangeBand()]);
// Y domain.
var y = d3.scale.linear()
.range([config.height, 0]);
var xAxis = d3.svg.axis()
.scale(x)
.orient("bottom");
var yAxis = d3.svg.axis()
.scale(y)
.orient("left")
.tickFormat(yaxisFormat);
var chartContainer = config.parent.append("g")
.attr("id", config.id)
.attr("transform", "translate(" + config.xoffset + "," + config.yoffset + ")");
var data = config.data;
// Translate all of the y data columns to numerics.
data.forEach(function(d)
{
config.yi.forEach(function(c)
{
d[c] = +d[c];
});
});
var yextent = dex.matrix.extent(data, config.yi);
x.domain(data.map(function(d) { return d[config.xi]; }));
//y.domain([0, d3.max(data, function(d) { return d[1]; })]);
if (config.ymin != null)
{
yextent[0] = config.ymin;
}
if (config.ymax != null)
{
yextent[1] = config.ymax;
}
// Establish the domain of the y axis.
y.domain(yextent);
// X Axis
chartContainer.append("g")
.attr("class", "x axis")
.attr("transform", "translate(0," + config.height + ")")
.call(xAxis)
.append("text")
.attr("y", 20)
.attr("dy", ".71em")
.style("text-anchor", "end")
.style("font-size", config.xaxisLabelFontSize)
.text(config.xaxisLabel);
// Y Axis
chartContainer.append("g")
.attr("class", "y axis")
.call(yAxis)
.append("text")
.attr("transform", "rotate(-90)")
.attr("y", 6)
.attr("dy", ".71em")
.style("text-anchor", "end")
.style("font-size", config.yaxisLabelFontSize)
.text(config.yaxisLabel);
var barData = dex.matrix.combine(
dex.matrix.slice(data, [config.xi]),
dex.matrix.slice(data, config.yi)
);
console.log("BarChart().BarData()")
console.dir(barData);
//console.dir(dex.matrix.slice(data, config.yi));
//console.dir(x.rangeBand());
chartContainer.selectAll(".bar")
.data(barData)
.enter().append("rect")
.attr("class", "bar")
.attr("x", function(d) { //console.dir(d);
return x(d[0]) + x1(d[3]) })
.style("fill", function(d) { return config.barColors(d[3]);})
.attr("width", x.rangeBand()/config.yi.length)
.attr("y", function(d) { return y(d[1]); })
.attr("height", function(d) { return config.height - y(d[1]); });
// Add Text Labels
/*
chartContainer.selectAll(".label")
.data(barData)
.enter().append("text")
.attr("x", function(d) { return x(d[0]) + x1(d[3]) })
.attr("y", function(d) { return y(d[1]); })
.attr("text-anchor", "end")
//.attr("transform", "rotate(90)")
.attr("dy", ".71em")
.style("font-size", 12)
.text(function(d) { console.log("TEXTD: " + d); return config.labels[d[3]]; });
*/
};
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...");
};
var dex =
{
version : "0.6",
matrix : {},
array : {},
csv : {}
};
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.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;
}
function getNumericHeaders(data)
{
var header = getHeader(data);
var possibleNumeric = {};
var i, j;
var numericHeaders = [];
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]])
{
numericHeaders.push(header[i]);
}
}
return numericHeaders;
}
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;
}
USStateMap.prototype = new DexComponent();
USStateMap.constructor = USStateMap;
function USStateMap(userConfig)
{
DexComponent.call(this, userConfig,
{
parent : null,
labels : [ "X", "Y" ],
width : 600,
height : 400,
xoffset : 0,
yoffset : 0,
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 path = d3.geo.path();
console.dir(this);
var chartContainer = config.parent.append("g")
.attr("id", "USStateMapContainer")
.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)
.on("click", function(d)
{
chart.notify({ type: "click", state : d.id });
})
};
/********************
* HTML CSS
*/
.chartWrap {
margin: 0;
padding: 0;
overflow: hidden;
}
/********************
* TOOLTIP CSS
*/
.nvtooltip {
position: absolute;
background-color: rgba(255,255,255,1);
padding: 1px;
border: 1px solid rgba(0,0,0,.2);
z-index: 10000;
font-family: Arial;
font-size: 13px;
transition: opacity 500ms linear;
-moz-transition: opacity 500ms linear;
-webkit-transition: opacity 500ms linear;
transition-delay: 500ms;
-moz-transition-delay: 500ms;
-webkit-transition-delay: 500ms;
-moz-box-shadow: 0 5px 10px rgba(0,0,0,.2);
-webkit-box-shadow: 0 5px 10px rgba(0,0,0,.2);
box-shadow: 0 5px 10px rgba(0,0,0,.2);
-webkit-border-radius: 6px;
-moz-border-radius: 6px;
border-radius: 6px;
pointer-events: none;
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.nvtooltip.x-nvtooltip,
.nvtooltip.y-nvtooltip {
padding: 8px;
}
.nvtooltip h3 {
margin: 0;
padding: 4px 14px;
line-height: 18px;
font-weight: normal;
background-color: #f7f7f7;
text-align: center;
border-bottom: 1px solid #ebebeb;
-webkit-border-radius: 5px 5px 0 0;
-moz-border-radius: 5px 5px 0 0;
border-radius: 5px 5px 0 0;
}
.nvtooltip p {
margin: 0;
padding: 5px 14px;
text-align: center;
}
.nvtooltip span {
display: inline-block;
margin: 2px 0;
}
.nvtooltip-pending-removal {
position: absolute;
pointer-events: none;
}
/********************
* SVG CSS
*/
svg {
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
/* Trying to get SVG to act like a greedy block in all browsers */
display: block;
width:100%;
height:100%;
}
svg text {
font: normal 12px Arial;
}
svg .title {
font: bold 14px Arial;
}
.nvd3 .nv-background {
fill: white;
fill-opacity: 0;
/*
pointer-events: none;
*/
}
.nvd3.nv-noData {
font-size: 18px;
font-weight: bold;
}
/**********
* Brush
*/
.nv-brush .extent {
fill-opacity: .125;
shape-rendering: crispEdges;
}
/**********
* Legend
*/
.nvd3 .nv-legend .nv-series {
cursor: pointer;
}
.nvd3 .nv-legend .disabled circle {
fill-opacity: 0;
}
/**********
* Axes
*/
.nvd3 .nv-axis path {
fill: none;
stroke: #000;
stroke-opacity: .75;
shape-rendering: crispEdges;
}
.nvd3 .nv-axis path.domain {
stroke-opacity: .75;
}
.nvd3 .nv-axis.nv-x path.domain {
stroke-opacity: 0;
}
.nvd3 .nv-axis line {
fill: none;
stroke: #000;
stroke-opacity: .25;
shape-rendering: crispEdges;
}
.nvd3 .nv-axis line.zero {
stroke-opacity: .75;
}
.nvd3 .nv-axis .nv-axisMaxMin text {
font-weight: bold;
}
.nvd3 .x .nv-axis .nv-axisMaxMin text,
.nvd3 .x2 .nv-axis .nv-axisMaxMin text,
.nvd3 .x3 .nv-axis .nv-axisMaxMin text {
text-anchor: middle
}
/**********
* Brush
*/
.nv-brush .resize path {
fill: #eee;
stroke: #666;
}
/**********
* Bars
*/
.nvd3 .nv-bars .negative rect {
zfill: brown;
}
.nvd3 .nv-bars rect {
zfill: steelblue;
fill-opacity: .75;
transition: fill-opacity 250ms linear;
-moz-transition: fill-opacity 250ms linear;
-webkit-transition: fill-opacity 250ms linear;
}
.nvd3 .nv-bars rect:hover {
fill-opacity: 1;
}
.nvd3 .nv-bars .hover rect {
fill: lightblue;
}
.nvd3 .nv-bars text {
fill: rgba(0,0,0,0);
}
.nvd3 .nv-bars .hover text {
fill: rgba(0,0,0,1);
}
/**********
* Bars
*/
.nvd3 .nv-multibar .nv-groups rect,
.nvd3 .nv-multibarHorizontal .nv-groups rect,
.nvd3 .nv-discretebar .nv-groups rect {
stroke-opacity: 0;
transition: fill-opacity 250ms linear;
-moz-transition: fill-opacity 250ms linear;
-webkit-transition: fill-opacity 250ms linear;
}
.nvd3 .nv-multibar .nv-groups rect:hover,
.nvd3 .nv-multibarHorizontal .nv-groups rect:hover,
.nvd3 .nv-discretebar .nv-groups rect:hover {
fill-opacity: 1;
}
.nvd3 .nv-discretebar .nv-groups text,
.nvd3 .nv-multibarHorizontal .nv-groups text {
font-weight: bold;
fill: rgba(0,0,0,1);
stroke: rgba(0,0,0,0);
}
/***********
* Pie Chart
*/
.nvd3.nv-pie path {
stroke-opacity: 0;
transition: fill-opacity 250ms linear, stroke-width 250ms linear, stroke-opacity 250ms linear;
-moz-transition: fill-opacity 250ms linear, stroke-width 250ms linear, stroke-opacity 250ms linear;
-webkit-transition: fill-opacity 250ms linear, stroke-width 250ms linear, stroke-opacity 250ms linear;
}
.nvd3.nv-pie .nv-slice text {
stroke: #000;
stroke-width: 0;
}
.nvd3.nv-pie path {
stroke: #fff;
stroke-width: 1px;
stroke-opacity: 1;
}
.nvd3.nv-pie .hover path {
fill-opacity: .7;
/*
stroke-width: 6px;
stroke-opacity: 1;
*/
}
.nvd3.nv-pie .nv-label rect {
fill-opacity: 0;
stroke-opacity: 0;
}
/**********
* Lines
*/
.nvd3 .nv-groups path.nv-line {
fill: none;
stroke-width: 2.5px;
/*
stroke-linecap: round;
shape-rendering: geometricPrecision;
transition: stroke-width 250ms linear;
-moz-transition: stroke-width 250ms linear;
-webkit-transition: stroke-width 250ms linear;
transition-delay: 250ms
-moz-transition-delay: 250ms;
-webkit-transition-delay: 250ms;
*/
}
.nvd3 .nv-groups path.nv-area {
stroke: none;
/*
stroke-linecap: round;
shape-rendering: geometricPrecision;
stroke-width: 2.5px;
transition: stroke-width 250ms linear;
-moz-transition: stroke-width 250ms linear;
-webkit-transition: stroke-width 250ms linear;
transition-delay: 250ms
-moz-transition-delay: 250ms;
-webkit-transition-delay: 250ms;
*/
}
.nvd3 .nv-line.hover path {
stroke-width: 6px;
}
/*
.nvd3.scatter .groups .point {
fill-opacity: 0.1;
stroke-opacity: 0.1;
}
*/
.nvd3.nv-line .nvd3.nv-scatter .nv-groups .nv-point {
fill-opacity: 0;
stroke-opacity: 0;
}
.nvd3.nv-scatter.nv-single-point .nv-groups .nv-point {
fill-opacity: .5 !important;
stroke-opacity: .5 !important;
}
.nvd3 .nv-groups .nv-point {
transition: stroke-width 250ms linear, stroke-opacity 250ms linear;
-moz-transition: stroke-width 250ms linear, stroke-opacity 250ms linear;
-webkit-transition: stroke-width 250ms linear, stroke-opacity 250ms linear;
}
.nvd3.nv-scatter .nv-groups .nv-point.hover,
.nvd3 .nv-groups .nv-point.hover {
stroke-width: 20px;
fill-opacity: .5 !important;
stroke-opacity: .5 !important;
}
.nvd3 .nv-point-paths path {
stroke: #aaa;
stroke-opacity: 0;
fill: #eee;
fill-opacity: 0;
}
.nvd3 .nv-indexLine {
cursor: ew-resize;
}
/**********
* Distribution
*/
.nvd3 .nv-distribution {
pointer-events: none;
}
/**********
* Scatter
*/
/* **Attempting to remove this for useVoronoi(false), need to see if it's required anywhere
.nvd3 .nv-groups .nv-point {
pointer-events: none;
}
*/
.nvd3 .nv-groups .nv-point.hover {
stroke-width: 20px;
stroke-opacity: .5;
}
.nvd3 .nv-scatter .nv-point.hover {
fill-opacity: 1;
}
/*
.nv-group.hover .nv-point {
fill-opacity: 1;
}
*/
/**********
* Stacked Area
*/
.nvd3.nv-stackedarea path.nv-area {
fill-opacity: .7;
/*
stroke-opacity: .65;
fill-opacity: 1;
*/
stroke-opacity: 0;
transition: fill-opacity 250ms linear, stroke-opacity 250ms linear;
-moz-transition: fill-opacity 250ms linear, stroke-opacity 250ms linear;
-webkit-transition: fill-opacity 250ms linear, stroke-opacity 250ms linear;
/*
transition-delay: 500ms;
-moz-transition-delay: 500ms;
-webkit-transition-delay: 500ms;
*/
}
.nvd3.nv-stackedarea path.nv-area.hover {
fill-opacity: .9;
/*
stroke-opacity: .85;
*/
}
/*
.d3stackedarea .groups path {
stroke-opacity: 0;
}
*/
.nvd3.nv-stackedarea .nv-groups .nv-point {
stroke-opacity: 0;
fill-opacity: 0;
}
.nvd3.nv-stackedarea .nv-groups .nv-point.hover {
stroke-width: 20px;
stroke-opacity: .75;
fill-opacity: 1;
}
/**********
* Line Plus Bar
*/
.nvd3.nv-linePlusBar .nv-bar rect {
fill-opacity: .75;
}
.nvd3.nv-linePlusBar .nv-bar rect:hover {
fill-opacity: 1;
}
/**********
* Bullet
*/
.nvd3.nv-bullet { font: 10px sans-serif; }
.nvd3.nv-bullet .nv-measure { fill-opacity: .8; }
.nvd3.nv-bullet .nv-measure:hover { fill-opacity: 1; }
.nvd3.nv-bullet .nv-marker { stroke: #000; stroke-width: 2px; }
.nvd3.nv-bullet .nv-markerTriangle { stroke: #000; fill: #fff; stroke-width: 1.5px; }
.nvd3.nv-bullet .nv-tick line { stroke: #666; stroke-width: .5px; }
.nvd3.nv-bullet .nv-range.nv-s0 { fill: #eee; }
.nvd3.nv-bullet .nv-range.nv-s1 { fill: #ddd; }
.nvd3.nv-bullet .nv-range.nv-s2 { fill: #ccc; }
.nvd3.nv-bullet .nv-title { font-size: 14px; font-weight: bold; }
.nvd3.nv-bullet .nv-subtitle { fill: #999; }
.nvd3.nv-bullet .nv-range {
fill: #999;
fill-opacity: .4;
}
.nvd3.nv-bullet .nv-range:hover {
fill-opacity: .7;
}
/**********
* Sparkline
*/
.nvd3.nv-sparkline path {
fill: none;
}
.nvd3.nv-sparklineplus g.nv-hoverValue {
pointer-events: none;
}
.nvd3.nv-sparklineplus .nv-hoverValue line {
stroke: #333;
stroke-width: 1.5px;
}
.nvd3.nv-sparklineplus,
.nvd3.nv-sparklineplus g {
pointer-events: all;
}
.nvd3 .nv-hoverArea {
fill-opacity: 0;
stroke-opacity: 0;
}
.nvd3.nv-sparklineplus .nv-xValue,
.nvd3.nv-sparklineplus .nv-yValue {
/*
stroke: #666;
*/
stroke-width: 0;
font-size: .9em;
font-weight: normal;
}
.nvd3.nv-sparklineplus .nv-yValue {
stroke: #f66;
}
.nvd3.nv-sparklineplus .nv-maxValue {
stroke: #2ca02c;
fill: #2ca02c;
}
.nvd3.nv-sparklineplus .nv-minValue {
stroke: #d62728;
fill: #d62728;
}
.nvd3.nv-sparklineplus .nv-currentValue {
/*
stroke: #444;
fill: #000;
*/
font-weight: bold;
font-size: 1.1em;
}
/**********
* historical stock
*/
.nvd3.nv-ohlcBar .nv-ticks .nv-tick {
stroke-width: 2px;
}
.nvd3.nv-ohlcBar .nv-ticks .nv-tick.hover {
stroke-width: 4px;
}
.nvd3.nv-ohlcBar .nv-ticks .nv-tick.positive {
stroke: #2ca02c;
}
.nvd3.nv-ohlcBar .nv-ticks .nv-tick.negative {
stroke: #d62728;
}
.nvd3.nv-historicalStockChart .nv-axis .nv-axislabel {
font-weight: bold;
}
.nvd3.nv-historicalStockChart .nv-dragTarget {
fill-opacity: 0;
stroke: none;
cursor: move;
}
.nvd3 .nv-brush .extent {
/*
cursor: ew-resize !important;
*/
fill-opacity: 0 !important;
}
.nvd3 .nv-brushBackground rect {
stroke: #000;
stroke-width: .4;
fill: #fff;
fill-opacity: .7;
}
/**********
* Indented Tree
*/
/**
* TODO: the following 3 selectors are based on classes used in the example. I should either make them standard and leave them here, or move to a CSS file not included in the library
*/
.nvd3.nv-indentedtree .name {
margin-left: 5px;
}
.nvd3.nv-indentedtree .clickable {
color: #08C;
cursor: pointer;
}
.nvd3.nv-indentedtree span.clickable:hover {
color: #005580;
text-decoration: underline;
}
.nvd3.nv-indentedtree .nv-childrenCount {
display: inline-block;
margin-left: 5px;
}
.nvd3.nv-indentedtree .nv-treeicon {
cursor: pointer;
/*
cursor: n-resize;
*/
}
.nvd3.nv-indentedtree .nv-treeicon.nv-folded {
cursor: pointer;
/*
cursor: s-resize;
*/
}
/* Inspired by Lee Byron's test data generator. */
function stream_layers(n, m, o) {
if (arguments.length < 3) o = 0;
function bump(a) {
var x = 1 / (.1 + Math.random()),
y = 2 * Math.random() - .5,
z = 10 / (.1 + Math.random());
for (var i = 0; i < m; i++) {
var w = (i / m - y) * z;
a[i] += x * Math.exp(-w * w);
}
}
return d3.range(n).map(function() {
var a = [], i;
for (i = 0; i < m; i++) a[i] = o + o * Math.random();
for (i = 0; i < 5; i++) bump(a);
return a.map(stream_index);
});
}
/* Another layer generator using gamma distributions. */
function stream_waves(n, m) {
return d3.range(n).map(function(i) {
return d3.range(m).map(function(j) {
var x = 20 * j / m - i / 3;
return 2 * x * Math.exp(-.5 * x);
}).map(stream_index);
});
}
function stream_index(d, i) {
return {x: i, y: Math.max(0, d)};
}