|
|
|
@ -25,7 +25,7 @@ const santaliColor = "#96bf60" // Santhali
|
|
|
|
|
const sindhiColor = "#e89931" // Sindhi
|
|
|
|
|
const awadhiColor = "#847fb5" // Awadhi
|
|
|
|
|
|
|
|
|
|
const unavailLangColor = "#555555"
|
|
|
|
|
const defaultColor = "#555555"
|
|
|
|
|
|
|
|
|
|
const languages = {
|
|
|
|
|
tamil: {name: "Tamil", color: tamilColor, code: "ta", districts: []},
|
|
|
|
@ -52,7 +52,6 @@ const languages = {
|
|
|
|
|
santali: {name: "Santali", color: santaliColor, code: "sat", districts: []},
|
|
|
|
|
sindhi: {name: "Sindhi", color: sindhiColor, code: "sd", districts: []},
|
|
|
|
|
awadhi: {name: "Awadhi", color: awadhiColor, code: "awa", districts: []},
|
|
|
|
|
unavail: {name: "Unavailable", color: unavailLangColor, code: "unavailable", districts: []},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Credit: https://www.artcraftblend.com/blogs/colors/shades-of-pastel
|
|
|
|
@ -71,12 +70,9 @@ const state2lang = {
|
|
|
|
|
"Jharkhand": languages["hindi"], // DEFAULT
|
|
|
|
|
"West Bengal": languages["bengali"],
|
|
|
|
|
"Assam": languages["assamese"],
|
|
|
|
|
"Meghalaya": languages["unavail"], // DEFAULT
|
|
|
|
|
"Tripura": languages["bengali"],
|
|
|
|
|
"Mizoram": languages["mizo"],
|
|
|
|
|
"Manipur": languages["manipuri"],
|
|
|
|
|
"Nagaland": languages["unavail"], // DEFAULT
|
|
|
|
|
"Arunachal Pradesh": languages["unavail"], // DEFAULT
|
|
|
|
|
"Sikkim": languages["nepali"],
|
|
|
|
|
"Bihar": languages["bhojpuri"],
|
|
|
|
|
"Madhya Pradesh": languages["hindi"],
|
|
|
|
@ -91,7 +87,6 @@ const state2lang = {
|
|
|
|
|
"Dadra and Nagar Haveli and Daman and Diu": languages["gujarati"],
|
|
|
|
|
"Puducherry": languages["tamil"],
|
|
|
|
|
"Lakshadweep": languages["malayalam"],
|
|
|
|
|
"Andaman and Nicobar Islands": languages["unavail"],
|
|
|
|
|
"Delhi": languages["hindi"],
|
|
|
|
|
"Chandigarh": languages["hindi"]
|
|
|
|
|
|
|
|
|
@ -239,15 +234,26 @@ function drawMap(world) {
|
|
|
|
|
.attr("class", d => stateOrDistrictOrLanguage(d))
|
|
|
|
|
.attr("fill", function(d) {
|
|
|
|
|
if (stateOrDistrictOrLanguage(d) === "district") {
|
|
|
|
|
return district2lang.hasOwnProperty(d.properties.district) ?
|
|
|
|
|
district2lang[d.properties.district].color :
|
|
|
|
|
state2lang[d.properties.st_nm].color
|
|
|
|
|
if (district2lang.hasOwnProperty(d.properties.district)) {
|
|
|
|
|
return district2lang[d.properties.district].color;
|
|
|
|
|
} else if (state2lang.hasOwnProperty(d.properties.st_nm)) {
|
|
|
|
|
return state2lang[d.properties.st_nm].color;
|
|
|
|
|
} else {
|
|
|
|
|
return defaultColor;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.each(function(d) {
|
|
|
|
|
if (stateOrDistrictOrLanguage(d) === "district") {
|
|
|
|
|
districtLang = district2lang.hasOwnProperty(d.properties.district) ? district2lang[d.properties.district] : state2lang[d.properties.st_nm];
|
|
|
|
|
districtLang.districts.push(d)
|
|
|
|
|
let districtLang;
|
|
|
|
|
if (district2lang.hasOwnProperty(d.properties.district)) {
|
|
|
|
|
districtLang = district2lang[d.properties.district];
|
|
|
|
|
} else if (state2lang.hasOwnProperty(d.properties.st_nm)) {
|
|
|
|
|
districtLang = state2lang[d.properties.st_nm];
|
|
|
|
|
}
|
|
|
|
|
if (typeof districtLang !== 'undefined') {
|
|
|
|
|
districtLang.districts.push(d)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.append("title") // Tooltip
|
|
|
|
@ -259,13 +265,19 @@ function drawMap(world) {
|
|
|
|
|
.attr("text-anchor", "middle")
|
|
|
|
|
.attr("font-size", "12px")
|
|
|
|
|
.attr("fill", "black")
|
|
|
|
|
.attr("class", "languageText")
|
|
|
|
|
.attr("id", d => d.properties.lang_name+"Text")
|
|
|
|
|
.attr("class", "languageText")
|
|
|
|
|
.attr("id", function(d) {
|
|
|
|
|
if (stateOrDistrictOrLanguage(d) == "language") {
|
|
|
|
|
return d.properties.lang_code+"Text"
|
|
|
|
|
} else {
|
|
|
|
|
d3.select(this).remove()
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.text(function(d) {
|
|
|
|
|
if (stateOrDistrictOrLanguage(d) == "language") {
|
|
|
|
|
return d.properties.lang_name;
|
|
|
|
|
} else {
|
|
|
|
|
return d.properties.district;
|
|
|
|
|
d3.select(this).remove() // Only add text if the element is a language
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
@ -291,6 +303,7 @@ function drawMap(world) {
|
|
|
|
|
// let outerBound = getOuterBoundaryPolygon(geojson.features)
|
|
|
|
|
// outerBound["id"] = "lang" + lang.name
|
|
|
|
|
// outerBound.properties["lang_name"]= lang.name
|
|
|
|
|
// outerBound.properties["lang_code"]= lang.code
|
|
|
|
|
// allLangs.push(outerBound);
|
|
|
|
|
|
|
|
|
|
// svg.append("path")
|
|
|
|
|