Jump to: navigation, search

Difference between revisions of "Widget:PnChoropleths"

m
m
 
(8 intermediate revisions by the same user not shown)
Line 232: Line 232:
 
'<tr><td>Miscellaneous</td><td colspan="2">' + d.Miscellaneous + '</td></tr>' +  
 
'<tr><td>Miscellaneous</td><td colspan="2">' + d.Miscellaneous + '</td></tr>' +  
 
'<tr><td>Total count</td><td colspan="2">' + d.total + '</td></tr>' +  
 
'<tr><td>Total count</td><td colspan="2">' + d.total + '</td></tr>' +  
'<tr><td>Count idx.</td><td>' + d.totalidx + '</td><td style="background-color:#' + d.totalcol + '; width:1.5em;"></td></tr>' +  
+
'<tr><td>Count idx.</td><td>' + d.totalidx + '</td><td style="background-color:' + d.totalcol + '; width:1.5em;"></td></tr>' +  
'<tr><td>PN/km<sup>2</sup> idx.</td><td>' + d.pnperkm2idx + '</td><td style="background-color:#' + d.pnperkm2col + '; width:1.5em;"></td></tr>' +  
+
'<tr><td>PN/km<sup>2</sup> idx.</td><td>' + d.pnperkm2idx + '</td><td style="background-color:' + d.pnperkm2col + '; width:1.5em;"></td></tr>' +  
'<tr><td>PN/km<sup>2</sup>/pop. idx.</td><td>' + d.pnperkm2popidx + '</td><td style="background-color:#' + d.pnperkm2popcol + '; width:1.5em;"></td></tr>' +
+
'<tr><td>PN/km<sup>2</sup>/pop. idx.</td><td>' + d.pnperkm2popidx + '</td><td style="background-color:' + d.pnperkm2popcol + '; width:1.5em;"></td></tr>' +  
'</tbody>';
 
return txt;
 
}
 
 
 
}() );
 
 
 
 
 
 
 
//Choropleth
 
( function() {
 
 
window.IRHB = window.IRHB || {};
 
var w = window.IRHB;
 
var d = w.data;
 
w.choro = {};
 
var c = w.choro;
 
var get = w.get;
 
 
 
 
c.choropleth = function() {
 
var curMap = w.map.curMap;
 
var mp = get(curMap);
 
var svg = mp.childNodes.length > 1 ? mp.firstChild.nextSibling.firstChild : mp.firstChild.firstChild;
 
var paths = svg.getElementsByTagName("path");
 
if (curMap === "navMap") {
 
for (var key in d.counties) {
 
var cur = d.counties[key];
 
paths[cur.path].style.stroke = "#ffffff";
 
}
 
} else {
 
if (w.nav.choroVar === "count") {
 
for (var key in d.counties) {
 
var cur = d.counties[key];
 
paths[cur.path].style.fill = cur.totalcol;
 
paths[cur.path].style.stroke = "#ffffff";
 
}
 
} else if (w.nav.choroVar === "area") {
 
for (var key in d.counties) {
 
var cur = d.counties[key];
 
paths[cur.path].style.fill = cur.pnperkm2col;
 
paths[cur.path].style.stroke = "#ffffff";
 
}
 
} else {
 
for (var key in d.counties) {
 
var cur = d.counties[key];
 
paths[cur.path].style.fill = cur.pnperkm2popcol;
 
paths[cur.path].style.stroke = "#ffffff";
 
}
 
}
 
}
 
};
 
 
 
}() );
 
 
 
 
 
 
 
//Map
 
( function() {
 
 
window.IRHB = window.IRHB || {};
 
var w = window.IRHB;
 
w.map = {};
 
var m = w.map, d = w.data, get = w.get;
 
var tooltip, features, zoom, tooltipOffset;
 
m.curMap = false;
 
 
 
function makeResponsive(svg) {
 
var container = d3.select(svg.node().parentNode),
 
w = parseInt(svg.style("width")),
 
h = parseInt(svg.style("height")),
 
aspect = w / h;
 
svg.attr("viewBox", "0 0 " + w + " " + h)
 
.attr("preserveAspectRatio", "xMinYMid")
 
.call(resize);
 
d3.select(window).on("resize." + container.attr("id"), resize);
 
 
 
function resize() {
 
var targetWidth = parseInt(container.style("width"));
 
svg.attr("width", targetWidth);
 
svg.attr("height", Math.round(targetWidth / aspect));
 
}
 
}
 
 
 
m.prepareMap = function() {
 
var mp = get(m.curMap);
 
var width = 496, height = 550;
 
var projection = d3.geo.conicEqualArea().scale(5165.269352442655).center([-1.4602454263940616,52.55675714793008]).parallels([49.95898294542323,55.81107189358492]).rotate([1.4602454263940616]).translate([202.798519176517,306.70813464248357]);
 
var path = d3.geo.path().projection(projection);
 
var svg = d3.select("div#" + m.curMap).append("svg").attr("width", width).attr("height", height);
 
if (mp.childNodes.length > 1) {
 
mp.firstChild.nextSibling.style.display = "none";
 
}
 
features = svg.append("g").attr("class","features");
 
tooltip = d3.select("body").append("div").attr("class","ttip");
 
d3.json("/wiki/geo/england/country/England.json",function(error,geodata) {
 
if (!error) {
 
features.selectAll("path").data(geodata.features).enter().append("path")
 
.attr("d",path).on("mouseover",showTooltip).on("mousemove",moveTooltip)
 
.on("mouseout",hideTooltip).on("click",clicked);
 
w.choro.choropleth();
 
if (mp.childNodes.length > 1) {
 
mp.removeChild(mp.childNodes[0]);
 
}
 
mp.firstChild.style.display = "block";
 
makeResponsive(svg);
 
} else {
 
return console.log(error);
 
}
 
});
 
tooltipOffset = {x: 5, y: -25};
 
}
 
 
 
 
m.initMap = function() {
 
d.calcStats();
 
};
 
 
 
m.addSpinner = function (elem) {
 
var svg = '<svg version="1.1" id="L9" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 100 100" enable-background="new 0 0 0 0" xml:space="preserve">';
 
svg += '<path fill="#fff" d="M73,50c0-12.7-10.3-23-23-23S27,37.3,27,50 M30.9,50c0-10.5,8.5-19.1,19.1-19.1S69.1,39.5,69.1,50">';
 
svg += '<animateTransform attributeName="transform" attributeType="XML" type="rotate" dur="2s" from="0 50 50" to="360 50 50" repeatCount="indefinite"/>';
 
svg += '</path></svg>';
 
elem.innerHTML = svg;
 
};
 
 
 
 
 
function clicked(d, i) {
 
location.href = encodeURIComponent(d.properties.name) + " place-names";
 
}
 
 
 
 
 
function showTooltip(d) {
 
moveTooltip();
 
tooltip.style("display","block").text(d.properties.abbrev);
 
}
 
 
 
 
 
function moveTooltip() {
 
tooltip.style("top",(d3.event.pageY+tooltipOffset.y)+"px").style("left",(d3.event.pageX+tooltipOffset.x)+"px");
 
}
 
 
 
 
 
function hideTooltip() {
 
tooltip.style("display","none");
 
}
 
 
}() );
 
 
 
 
 
 
 
//Navigation
 
( function() {
 
 
window.IRHB = window.IRHB || {};
 
var w = window.IRHB;
 
w.nav = {};
 
var n = w.nav;
 
var get = w.get;
 
var m = w.map;
 
var choroLegend = {
 
'count': { 's1': 'Count', 's2': 'Area', 's3': 'Area&ndash;Population'},
 
'area': { 's1': 'Area', 's2': 'Count', 's3': 'Area&ndash;Population'},
 
'areaPop': { 's1': 'Area&ndash;Population', 's2': 'Count', 's3': 'Area'}
 
}
 
n.choroVar = "count";
 
 
 
function selectChoroVar(event) {
 
var targId = event.target.id;
 
if (targId === "choroMapLegend2") {
 
if (n.choroVar !== "count") {
 
n.choroVar = "count";
 
} else {
 
n.choroVar = "area";
 
}
 
} else {
 
if (n.choroVar !== "areaPop") {
 
n.choroVar = "areaPop";
 
} else {
 
n.choroVar = "area";
 
}
 
}
 
get("choroMapLegend1").innerHTML = choroLegend[n.choroVar].s1;
 
get("choroMapLegend2").innerHTML = choroLegend[n.choroVar].s2;
 
get("choroMapLegend3").innerHTML = choroLegend[n.choroVar].s3;
 
w.choro.choropleth();
 
}
 
 
 
 
n.prepareNav = function() {
 
var d = get("choroMapLegend2");
 
d.onclick = selectChoroVar;
 
d.style.fontWeight = 600;
 
d.style.color = "#4d8375";
 
d.style.cursor = "pointer";
 
d = get("choroMapLegend3");
 
d.onclick = selectChoroVar;
 
d.style.fontWeight = 600;
 
d.style.color = "#4d8375";
 
d.style.cursor = "pointer";
 
get("choroMap").style.backgroundColor = "#f9fafa";
 
n.toggleNav();
 
};
 
 
 
 
n.toggleNav = function() {
 
get("choroMapLegend1").innerHTML = choroLegend[n.choroVar].s1;
 
get("choroMapLegend2").innerHTML = choroLegend[n.choroVar].s2;
 
get("choroMapLegend3").innerHTML = choroLegend[n.choroVar].s3;
 
get("choroMap").style.display = "block";
 
get("choroMapLegend").style.display = "block";
 
m.curMap = "choroMap";
 
m.initMap();
 
};
 
 
 
}() );
 
 
 
 
 
 
 
( function() {
 
 
 
    var w = window.IRHB;
 
    var gjson = "https://www.irhb.org/wiki/geo/england/country/England.json";
 
    var script = document.createElement('script');
 
    script.type = 'text/javascript';
 
    script.src = "https://www.irhb.org/wiki/js/d3js/d3.v3.min.js";
 
    script.onload = w.nav.prepareNav;
 
    document.head.appendChild(script);
 
 
}() );
 
 
window.IRHB = window.IRHB || {};
 
 
window.IRHB.get = window.IRHB.get || function(elem) {
 
if (typeof elem === "string") {
 
elem = document.getElementById(elem);
 
}
 
return elem;
 
};
 
 
}() );
 
 
 
 
 
 
 
//Data
 
( function() {
 
 
window.IRHB = window.IRHB || {};
 
var w = window.IRHB;
 
w.data = {};
 
var d = w.data;
 
d.stats = false;
 
var get = w.get;
 
 
 
d.colours = [
 
{limit: 10, rgb: "a30000"}, {limit: 20, rgb: "b70000"}, {limit: 30, rgb: "d11919"}, {limit: 40, rgb: "db4c4c"}, {limit: 50, rgb: "e06666"}, {limit: 60, rgb: "e57f7f"},
 
{limit: 70, rgb: "ea9999"}, {limit: 80, rgb: "efb2b2"}, {limit: 90, rgb: "f4cccc"}, {limit: 100, rgb: "f9e5e5"}, {limit: 110, rgb: "ffffff"}, {limit: 120, rgb: "f9faf9"},
 
{limit: 130, rgb: "f3f5f3"}, {limit: 140, rgb: "ecefec"}, {limit: 150, rgb: "d9e0da"}, {limit: 160, rgb: "c7d0c7"}, {limit: 170, rgb: "b4c1b5"}, {limit: 180, rgb: "a2b1a3"},
 
{limit: 190, rgb: "8fa290"}, {limit: 200, rgb: "7c927e"}, {limit: 300, rgb: "6a836b"}, {limit: 400, rgb: "577359"}, {limit: 500, rgb: "456447"}, {limit: 600, rgb: "3e5a3f"},
 
{limit: 700, rgb: "375038"}, {limit: 800, rgb: "304631"}, {limit: 900, rgb: "293c2a"}, {limit: 1000, rgb: "223223"}, {limit: 1500, rgb: "1b281c"}, {limit: 2000, rgb: "141e15"}
 
];
 
var nCols = d.colours.length;
 
 
d.England = {'Robin Hood name': 0, 'Local tradition': 0, 'Literary locale': 0, 'Artifacts': 0, 'Miscellaneous': 0, 'total': 0};
 
 
d.counties = {
 
'Bedfordshire': {'path': 1, 'Robin Hood name': 0, 'Local tradition': 0, 'Literary locale': 0, 'Artifacts': 0, 'Miscellaneous': 0, 'total': 0},
 
'Berkshire': {'path': 2, 'Robin Hood name': 0, 'Local tradition': 0, 'Literary locale': 0, 'Artifacts': 0, 'Miscellaneous': 0, 'total': 0},
 
'Buckinghamshire': {'path': 3, 'Robin Hood name': 0, 'Local tradition': 0, 'Literary locale': 0, 'Artifacts': 0, 'Miscellaneous': 0, 'total': 0},
 
'Cambridgeshire': {'path': 4, 'Robin Hood name': 0, 'Local tradition': 0, 'Literary locale': 0, 'Artifacts': 0, 'Miscellaneous': 0, 'total': 0},
 
'Cheshire': {'path': 5, 'Robin Hood name': 0, 'Local tradition': 0, 'Literary locale': 0, 'Artifacts': 0, 'Miscellaneous': 0, 'total': 0},
 
'Cornwall': {'path': 6, 'Robin Hood name': 0, 'Local tradition': 0, 'Literary locale': 0, 'Artifacts': 0, 'Miscellaneous': 0, 'total': 0},
 
'Cumberland': {'path': 0, 'Robin Hood name': 0, 'Local tradition': 0, 'Literary locale': 0, 'Artifacts': 0, 'Miscellaneous': 0, 'total': 0},
 
'Derbyshire': {'path': 7, 'Robin Hood name': 0, 'Local tradition': 0, 'Literary locale': 0, 'Artifacts': 0, 'Miscellaneous': 0, 'total': 0},
 
'Devon': {'path': 8, 'Robin Hood name': 0, 'Local tradition': 0, 'Literary locale': 0, 'Artifacts': 0, 'Miscellaneous': 0, 'total': 0},
 
'Dorset': {'path': 9, 'Robin Hood name': 0, 'Local tradition': 0, 'Literary locale': 0, 'Artifacts': 0, 'Miscellaneous': 0, 'total': 0},
 
'Durham': {'path': 10, 'Robin Hood name': 0, 'Local tradition': 0, 'Literary locale': 0, 'Artifacts': 0, 'Miscellaneous': 0, 'total': 0},
 
'Essex': {'path': 11, 'Robin Hood name': 0, 'Local tradition': 0, 'Literary locale': 0, 'Artifacts': 0, 'Miscellaneous': 0, 'total': 0},
 
'Gloucestershire': {'path': 12, 'Robin Hood name': 0, 'Local tradition': 0, 'Literary locale': 0, 'Artifacts': 0, 'Miscellaneous': 0, 'total': 0},
 
'Hampshire': {'path': 13, 'Robin Hood name': 0, 'Local tradition': 0, 'Literary locale': 0, 'Artifacts': 0, 'Miscellaneous': 0, 'total': 0},
 
'Herefordshire': {'path': 14, 'Robin Hood name': 0, 'Local tradition': 0, 'Literary locale': 0, 'Artifacts': 0, 'Miscellaneous': 0, 'total': 0},
 
'Hertfordshire': {'path': 15, 'Robin Hood name': 0, 'Local tradition': 0, 'Literary locale': 0, 'Artifacts': 0, 'Miscellaneous': 0, 'total': 0},
 
'Huntingdonshire': {'path': 16, 'Robin Hood name': 0, 'Local tradition': 0, 'Literary locale': 0, 'Artifacts': 0, 'Miscellaneous': 0, 'total': 0},
 
'Kent': {'path': 17, 'Robin Hood name': 0, 'Local tradition': 0, 'Literary locale': 0, 'Artifacts': 0, 'Miscellaneous': 0, 'total': 0},
 
'Lancashire': {'path': 18, 'Robin Hood name': 0, 'Local tradition': 0, 'Literary locale': 0, 'Artifacts': 0, 'Miscellaneous': 0, 'total': 0},
 
'Leicestershire': {'path': 19, 'Robin Hood name': 0, 'Local tradition': 0, 'Literary locale': 0, 'Artifacts': 0, 'Miscellaneous': 0, 'total': 0},
 
'Lincolnshire': {'path': 20, 'Robin Hood name': 0, 'Local tradition': 0, 'Literary locale': 0, 'Artifacts': 0, 'Miscellaneous': 0, 'total': 0},
 
'Middlesex': {'path': 21, 'Robin Hood name': 0, 'Local tradition': 0, 'Literary locale': 0, 'Artifacts': 0, 'Miscellaneous': 0, 'total': 0},
 
'Norfolk': {'path': 22, 'Robin Hood name': 0, 'Local tradition': 0, 'Literary locale': 0, 'Artifacts': 0, 'Miscellaneous': 0, 'total': 0},
 
'Northamptonshire': {'path': 23, 'Robin Hood name': 0, 'Local tradition': 0, 'Literary locale': 0, 'Artifacts': 0, 'Miscellaneous': 0, 'total': 0},
 
'Northumberland': {'path': 24, 'Robin Hood name': 0, 'Local tradition': 0, 'Literary locale': 0, 'Artifacts': 0, 'Miscellaneous': 0, 'total': 0},
 
'Nottinghamshire': {'path': 25, 'Robin Hood name': 0, 'Local tradition': 0, 'Literary locale': 0, 'Artifacts': 0, 'Miscellaneous': 0, 'total': 0},
 
'Oxfordshire': {'path': 38, 'Robin Hood name': 0, 'Local tradition': 0, 'Literary locale': 0, 'Artifacts': 0, 'Miscellaneous': 0, 'total': 0},
 
'Rutland': {'path': 26, 'Robin Hood name': 0, 'Local tradition': 0, 'Literary locale': 0, 'Artifacts': 0, 'Miscellaneous': 0, 'total': 0},
 
'Shropshire': {'path': 27, 'Robin Hood name': 0, 'Local tradition': 0, 'Literary locale': 0, 'Artifacts': 0, 'Miscellaneous': 0, 'total': 0},
 
'Somerset': {'path': 28, 'Robin Hood name': 0, 'Local tradition': 0, 'Literary locale': 0, 'Artifacts': 0, 'Miscellaneous': 0, 'total': 0},
 
'Staffordshire': {'path': 29, 'Robin Hood name': 0, 'Local tradition': 0, 'Literary locale': 0, 'Artifacts': 0, 'Miscellaneous': 0, 'total': 0},
 
'Suffolk': {'path': 30, 'Robin Hood name': 0, 'Local tradition': 0, 'Literary locale': 0, 'Artifacts': 0, 'Miscellaneous': 0, 'total': 0},
 
'Surrey': {'path': 31, 'Robin Hood name': 0, 'Local tradition': 0, 'Literary locale': 0, 'Artifacts': 0, 'Miscellaneous': 0, 'total': 0},
 
'Sussex': {'path': 32, 'Robin Hood name': 0, 'Local tradition': 0, 'Literary locale': 0, 'Artifacts': 0, 'Miscellaneous': 0, 'total': 0},
 
'Warwickshire': {'path': 33, 'Robin Hood name': 0, 'Local tradition': 0, 'Literary locale': 0, 'Artifacts': 0, 'Miscellaneous': 0, 'total': 0},
 
'Westmorland': {'path': 34, 'Robin Hood name': 0, 'Local tradition': 0, 'Literary locale': 0, 'Artifacts': 0, 'Miscellaneous': 0, 'total': 0},
 
'Wiltshire': {'path': 35, 'Robin Hood name': 0, 'Local tradition': 0, 'Literary locale': 0, 'Artifacts': 0, 'Miscellaneous': 0, 'total': 0},
 
'Worcestershire': {'path': 36, 'Robin Hood name': 0, 'Local tradition': 0, 'Literary locale': 0, 'Artifacts': 0, 'Miscellaneous': 0, 'total': 0},
 
'Yorkshire': {'path': 37, 'Robin Hood name': 0, 'Local tradition': 0, 'Literary locale': 0, 'Artifacts': 0, 'Miscellaneous': 0, 'total': 0}
 
};
 
 
 
 
function getColour(val) {
 
var colour = "#000000";
 
for (var i = 0; i < nCols; i++) {
 
var cur = d.colours[i];
 
if (val <= cur.limit) {
 
colour = cur.rgb;
 
break;
 
}
 
}
 
return colour;
 
}
 
 
 
function calcCountyIndexes() {
 
d.England.pnperkm2idx = 100;
 
for (var key in d.counties) {
 
var cur = d.counties[key];
 
cur.pnperkm2 = cur.total / cur.area;
 
cur.km2perpn = cur.area / cur.total;
 
cur.pnperkm2idx = (cur.pnperkm2 / d.England.pnperkm2) * 100;
 
var expected = d.England.pnperkm2 * cur.area;
 
expected = (expected / d.England.popdensity) * cur.popdensity;
 
cur.pnperkm2popidx = (cur.total / expected) * 100;
 
cur.totalidx = cur.total !== 0 ? (cur.total / d.England.pnpercounty) * 100 : 0;
 
cur.totalcol = getColour(cur.totalidx);
 
cur.pnperkm2col = getColour(cur.pnperkm2idx);
 
cur.pnperkm2popcol = getColour(cur.pnperkm2popidx);
 
}
 
}
 
 
 
function calcCounties(res) {
 
var counties = res.query.results;
 
var numCounties = 0;
 
var engArea = 0, engPop = 0;
 
for (var key in counties) {
 
if (key.indexOf("Riding") === -1 && key.indexOf("London") === -1) {
 
var cty = key.replace(" place-names", "");
 
numCounties++;
 
var a = counties[key].printouts.Area[0];
 
d.counties[cty].area = a;
 
engArea += a;
 
var p = counties[key].printouts.Population[0];
 
d.counties[cty].population = p;
 
d.counties[cty].popdensity = p / a;
 
d.counties[cty].km2perperson = a / p;
 
engPop += p;
 
}
 
}
 
d.England.area = engArea;
 
d.England.population = engPop;
 
d.England.popdensity = engPop / engArea;
 
d.England.km2perperson = engArea / engPop;
 
d.England.counties = numCounties;
 
}
 
 
 
function calcPlaceNames(res) {
 
var PNs = res.query.results;
 
for (var key in PNs) {
 
var admdiv = PNs[key].printouts.Pnadmdiv[0];
 
var interest = PNs[key].printouts.Pninterest[0];
 
var admdivObj = d.counties[admdiv];
 
admdivObj.total++;
 
d.England.total++;
 
admdivObj[interest]++;
 
d.England[interest]++;
 
}
 
d.England.km2perpn = d.England.area / d.England.total;
 
d.England.pnperkm2 = d.England.total / d.England.area;
 
d.England.pnpercounty = d.England.total / d.England.counties;
 
calcCountyIndexes();
 
}
 
 
 
d.calcStats = function() {
 
if (!d.stats) {
 
w.map.addSpinner(get(w.map.curMap));
 
var url = "https://www.irhb.org/wiki/api.php?action=ask&query=[[Category:English%20counties%20with%20place-names]]|?Area|?Population&format=json";
 
fetch(url).then(res => res.json()).then((jsnCty) => {
 
calcCounties(jsnCty);
 
url = "https://www.irhb.org/wiki/api.php?action=ask&query=[[Category:English%20place-names]]|?Pninterest|?Pnadmdiv|sort=Pnadmdiv&format=json";
 
fetch(url).then(res => res.json()).then((jsnPN) => {
 
calcPlaceNames(jsnPN);
 
d.stats = true;
 
w.map.prepareMap();
 
prepareDataTable();
 
}).catch(err => { throw err });
 
}).catch(err => { throw err });
 
} else {
 
w.map.prepareMap();
 
}
 
};
 
 
 
function prepareDataTable() {
 
var e = window.IRHB.data.England;
 
var c = window.IRHB.data.counties;
 
 
var tables = '<table class="bordertable expando" id="choropleth1" style="margin-bottom:-1px;">' +
 
'<tbody id="england">' +
 
'<tr class="header"><th colspan="2">England</th><th><span class="expando-c">&#x2014;&#xa0;</span><span class="expando-o">&#x25a2;&#xa0;</span></th></tr>' +
 
'<tr><td>Artifact</td><td colspan="2">' + e.Artifacts + '</td></tr>' +
 
'<tr><td>Literary locale</td><td colspan="2">' + e["Literary locale"] + '</td></tr>' +
 
'<tr><td>Local tradition</td><td colspan="2">' + e["Local tradition"] + '</td></tr>' +
 
'<tr><td>Miscellaneous</td><td colspan="2">' + e.Miscellaneous + '</td></tr>' +
 
'<tr><td>Robin Hood name</td><td colspan="2">' + e["Robin Hood name"] + '</td></tr>' +
 
'<tr><td>Area (km<sup>2</sup>)</td><td colspan="2">' + e.area + '</td></tr>' +
 
'<tr><td>Population</td><td colspan="2">' + e.population + '</td></tr>' +
 
'<tr><td>Pop. density/km<sup>2</sup></td><td colspan="2">' + e.popdensity + '</td></tr>' +
 
'<tr><td>Place-names (PN)</td><td colspan="2">' + e.total + '</td></tr>' +
 
'<tr><td>Counties</td><td colspan="2">' + e.counties + '</td></tr>' +
 
'<tr><td>Km<sup>2</sup>/person</td><td colspan="2">' + e.km2perperson + '</td></tr>' +
 
'<tr><td>Km<sup>2</sup>/PN</td><td colspan="2">' + e.km2perpn + '</td></tr>' +
 
'<tr><td>PN/km<sup>2</sup></td><td colspan="2">' + e.pnperkm2 + '</td></tr>' +
 
'<tr><td>PN/km<sup>2</sup> idx</td><td colspan="2">' + e.pnperkm2idx + '</td></tr>' +
 
'<tr><td>PN/county avg.</td><td colspan="2">' + e.pnpercounty + '</td></tr>' +
 
'</tbody>';
 
 
var counties = Object.keys(c);
 
var nCounties = counties.length;
 
var idxLeics = 19;
 
for (var i = 0; i < idxLeics; i++) {
 
var cty = counties[i];
 
tables += getCountyData(cty, c[cty]);
 
}
 
tables += '</table>';
 
tables += '<table class="bordertable expando" id="choropleth2">';
 
for (var i = idxLeics; i < nCounties; i++) {
 
var cty = counties[i];
 
tables += getCountyData(cty, c[cty]);
 
}
 
tables += '</table>';
 
get("dSet").innerHTML = tables;
 
window.IRHB.expando.init();
 
};
 
 
 
function getCountyData(cty, d) {
 
var txt = '<tbody id="' + cty + '"><tr class="header"><th colspan="2">' + cty + '</th>' +
 
'<th><span class="expando-c">—&nbsp;</span><span class="expando-o">▢&nbsp;</span></th></tr>' +
 
'<tr><td style="width:129px;">Area (km<sup>2</sup>)</td><td colspan="2">' + d.area + '</td></tr>' +
 
'<tr><td>Population</td><td colspan="2">' + d.population + '</td></tr>' +
 
'<tr><td>Pop. density/km<sup>2</sup></td><td colspan="2">' + d.popdensity + '</td></tr>' +
 
'<tr><td>Km<sup>2</sup>/PN</td><td colspan="2">' + d.km2perpn + '</td></tr>' +
 
'<tr><td>PN/km<sup>2</sup></td><td colspan="2">' + d.pnperkm2 + '</td></tr>' +
 
'<tr><td>RH names</td><td colspan="2">' + d["Robin Hood name"] + '</td></tr>' +
 
'<tr><td>Local traditions</td><td colspan="2">' + d["Local tradition"] + '</td></tr>' +
 
'<tr><td>Literary locales</td><td colspan="2">' + d["Literary locale"] + '</td></tr>' +
 
'<tr><td>Artifacts</td><td colspan="2">' + d.Artifacts+ '</td></tr>' +
 
'<tr><td>Miscellaneous</td><td colspan="2">' + d.Miscellaneous + '</td></tr>' +
 
'<tr><td>Total count</td><td colspan="2">' + d.total + '</td></tr>' +
 
'<tr><td>Count idx.</td><td>' + d.totalidx + '</td><td style="background-color:#' + d.totalcol + '; width:1.5em;"></td></tr>' +
 
'<tr><td>PN/km<sup>2</sup> idx.</td><td>' + d.pnperkm2idx + '</td><td style="background-color:#' + d.pnperkm2col + '; width:1.5em;"></td></tr>' +
 
'<tr><td>PN/km<sup>2</sup>/pop. idx.</td><td>' + d.pnperkm2popidx + '</td><td style="background-color:#' + d.pnperkm2popcol + '; width:1.5em;"></td></tr>' +  
 
 
'</tbody>';
 
'</tbody>';
 
return txt;
 
return txt;
Line 828: Line 361:
 
svg += '</path></svg>';
 
svg += '</path></svg>';
 
elem.innerHTML = svg;
 
elem.innerHTML = svg;
 +
elem.firstElementChild.firstElementChild.style.strokeWidth = "0px";
 
};
 
};
 
 

Latest revision as of 15:09, 7 June 2019

This widget displays the navigation map on country and administrative division landing pages in the place-names section of IRHB. It takes no parameters.