Set romanization text relative to translation text; Fill languages instead of the individual districts
This commit is contained in:
33
index.js
33
index.js
@@ -213,13 +213,8 @@ function drawMap(world) {
|
|||||||
.attr("d", path)
|
.attr("d", path)
|
||||||
.attr("class", d => stateOrDistrictOrLanguage(d))
|
.attr("class", d => stateOrDistrictOrLanguage(d))
|
||||||
.attr("fill", function(d) {
|
.attr("fill", function(d) {
|
||||||
if (stateOrDistrictOrLanguage(d) === "district") {
|
if (stateOrDistrictOrLanguage(d) === "language") {
|
||||||
const districtLang = district2langFunc(d)
|
return languages[d.properties.lang_name.toLowerCase()].color;
|
||||||
if (typeof districtLang !== 'undefined') {
|
|
||||||
return districtLang.color
|
|
||||||
} else {
|
|
||||||
return defaultColor;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.each(function(d) {
|
.each(function(d) {
|
||||||
@@ -234,8 +229,20 @@ function drawMap(world) {
|
|||||||
.text(d => d.properties.district);
|
.text(d => d.properties.district);
|
||||||
|
|
||||||
states.append("text")
|
states.append("text")
|
||||||
.attr("x", d => projection(d3.geoCentroid(d))[0])
|
.attr("x", function(d) {
|
||||||
.attr("y", d => projection(d3.geoCentroid(d))[1])
|
if (stateOrDistrictOrLanguage(d) == "language") {
|
||||||
|
rtv = projection(d3.geoCentroid(d))[0];
|
||||||
|
if (d.properties.lang_name == "Kannada") {
|
||||||
|
rtv -= 10;
|
||||||
|
}
|
||||||
|
return rtv
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.attr("y", function(d) {
|
||||||
|
if (stateOrDistrictOrLanguage(d) == "language") {
|
||||||
|
return projection(d3.geoCentroid(d))[1]
|
||||||
|
}
|
||||||
|
})
|
||||||
.attr("text-anchor", "middle")
|
.attr("text-anchor", "middle")
|
||||||
.attr("font-size", "12px")
|
.attr("font-size", "12px")
|
||||||
.attr("fill", "black")
|
.attr("fill", "black")
|
||||||
@@ -256,8 +263,12 @@ function drawMap(world) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
states.append("text")
|
states.append("text")
|
||||||
.attr("x", d => projection(d3.geoCentroid(d))[0])
|
.attr("x", d => stateOrDistrictOrLanguage(d) == "language" ?
|
||||||
.attr("y", d => projection(d3.geoCentroid(d))[1] + parseFloat(getComputedStyle(document.getElementsByClassName('languageText')[0]).getPropertyValue('font-size')))
|
document.getElementById(d.properties.lang_code + "Text").getAttribute("x") :
|
||||||
|
projection(d3.geoCentroid(d))[0])
|
||||||
|
.attr("y", d => stateOrDistrictOrLanguage(d) == "language" ?
|
||||||
|
parseFloat(document.getElementById(d.properties.lang_code + "Text").getAttribute("y")) + parseFloat(getComputedStyle(document.getElementsByClassName('languageText')[0]).getPropertyValue('font-size')) :
|
||||||
|
projection(d3.geoCentroid(d))[1])
|
||||||
.attr("text-anchor", "middle")
|
.attr("text-anchor", "middle")
|
||||||
.attr("font-size", "12px")
|
.attr("font-size", "12px")
|
||||||
.attr("fill", "black")
|
.attr("fill", "black")
|
||||||
|
Reference in New Issue
Block a user