@makechart/twmapadv 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/README.md +12 -3
- package/index.html +1 -1
- package/package.json +1 -1
- package/sample//345/205/250/345/234/213.json +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# Change Logs
|
|
2
2
|
|
|
3
|
+
## v0.0.3
|
|
4
|
+
|
|
5
|
+
- `pdmaptw` 2.7.0: finer village boundaries, and no village lost in simplification
|
|
6
|
+
- tooltip stays at the upper left of the pointer and only flips where there is no room ( it used to jump
|
|
7
|
+
around inside large regions ), without blank lines between rows
|
|
8
|
+
- `tool/icon.js`: `--paths` writes the simplified town paths per county ( the site draws town icons with
|
|
9
|
+
them ); the point budget counts only the arcs the towns use
|
|
10
|
+
|
|
11
|
+
## v0.0.2
|
|
12
|
+
|
|
13
|
+
- more levels ( block data `level` ): `town` is the whole country, counties over towns, from the town
|
|
14
|
+
file and its `objects.county`; `county/<縣市>/<鄉鎮>` is one town over its villages. needs `pdmaptw` 2.6.0
|
|
15
|
+
- dimension names follow the level ( 縣市 / 鄉鎮 for the whole country )
|
|
16
|
+
- the map extent leaves out far away islands ( 東沙 / 南沙 under 高雄市旗津區 ), which are clipped
|
|
17
|
+
- national sample data `sample/全國.json`; a single town filters its county's sample
|
|
18
|
+
- `tool/icon.js`: per-county chart icons for `@makechart/iconset`
|
|
19
|
+
|
|
3
20
|
## v0.0.1
|
|
4
21
|
|
|
5
22
|
- first release. town / village map of one Taiwan county ( block data `level`, e.g. `county/臺北市` ),
|
package/README.md
CHANGED
|
@@ -2,7 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
縣市內的鄉鎮 / 村里地圖。地圖資料來自 `pdmaptw` ( 2.4.0 起的各縣市村里檔 )。
|
|
4
4
|
|
|
5
|
-
block data
|
|
5
|
+
block data `level` 決定畫哪兩層 ( 程式與資料的維度一律叫上層 `town`、下層 `village` ):
|
|
6
|
+
|
|
7
|
+
| level | 上層 / 下層 | 地圖檔 ( pdmaptw >= 2.6.0 ) |
|
|
8
|
+
| --- | --- | --- |
|
|
9
|
+
| `town` | 縣市 / 鄉鎮 ( 全國 ) | `town.map.js`, 上層是它的 `objects.county` |
|
|
10
|
+
| `county/<縣市>` ( 預設 `county/臺北市` ) | 鄉鎮 / 村里 | `county/<縣市>.village.map.js`, 上層是它的 `objects.town` |
|
|
11
|
+
| `county/<縣市>/<鄉鎮>` | 該鄉鎮 / 它的村里 | 同上, 只留這個鄉鎮 ( 名稱或 8 碼代碼 ) |
|
|
12
|
+
|
|
13
|
+
維度在編輯器裡的名稱依層級顯示 ( 全國是縣市 / 鄉鎮 ). 下層名稱可以帶上層的名字 ( `臺北市中正區` ).
|
|
14
|
+
地圖範圍不含遠方的小島 ( 例如東沙、南沙 ), 範圍外的部分會被裁掉.
|
|
6
15
|
|
|
7
16
|
鄉鎮的形狀用村里檔裡的 `objects.town` ( pdmaptw 2.5.0 起, 由村里合成、與村里共用 arc ), 不用鄉鎮檔:
|
|
8
17
|
兩個檔來自不同的 shapefile、各自簡化, 界線對不上, 一起畫時會錯開.
|
|
@@ -52,8 +61,8 @@ block data: `level`, 例如 `county/臺北市` ( 預設 ). 會載入 `<level>.ma
|
|
|
52
61
|
|
|
53
62
|
## 範例資料
|
|
54
63
|
|
|
55
|
-
每個縣市一個 `src/sample/<縣市>.json` ( build 時複製到 `dist/sample/` ),
|
|
56
|
-
載入那一個 ( 網址由 block manager 照 registry 規則組出 ). 由 `tool/sample.js` 產生
|
|
64
|
+
每個縣市一個 `src/sample/<縣市>.json`, 全國是 `src/sample/全國.json` ( build 時複製到 `dist/sample/` ),
|
|
65
|
+
`sample()` 執行時才依 `level` 載入那一個 ( 單一鄉鎮從縣市檔篩出 ) ( 網址由 block manager 照 registry 規則組出 ). 由 `tool/sample.js` 產生
|
|
57
66
|
( 內政部戶政司 ODRP014 村里戶數、單一年齡人口; 面積取自 pdmaptw ):
|
|
58
67
|
|
|
59
68
|
node tool/sample.js 11409 ../../../plotdb/projects/pdmaptw # 全部縣市
|
package/index.html
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
<div><style type="text/css">.pdl-layout>div[data-type=layout]{display:grid;grid-template-columns:1fr fit-content(8em);grid-template-rows:1fr auto}.pdl-layout>div[data-type=layout]>.pdl-cell[data-name=view]{grid-row:1/span 2}.pdl-layout>div[data-type=layout]>.pdl-cell[data-name=legend]{padding-left:1em}.pdl-layout.legend-bottom>div[data-type=layout]{grid-template-columns:1fr;grid-template-rows:1fr auto auto}.pdl-layout.legend-bottom>div[data-type=layout]>.pdl-cell[data-name=view]{grid-row:auto}.pdl-layout.legend-bottom>div[data-type=layout]>.pdl-cell[data-name=legend]{padding:1em 0 0 0}.pdl-cell[data-name=scale]{padding:.5em}.pdl-cell[data-name=scale]>div{width:4.5em;height:10em}.pdl-layout.legend-bottom .pdl-cell[data-name=scale]>div{width:auto;height:2em}</style><script type="@plotdb/block">var svgns,tau,mk,ringArea,ringCentroid,metrics,clone,eachPoint,cartogram,relax,pieArcs,wedge,toRgb,rgbStr,ramp,rank,unrank,palettes,townWords,mod;module.exports={pkg:{name:"twmapadv",version:"0.0.1",extend:{name:"@makechart/base",path:"lite/index.html"},dependencies:[{name:"topojson-client",version:"3.1.0",path:"dist/topojson-client.min.js",async:false},{name:"d3-array",version:"3.2.4",path:"dist/d3-array.min.js",async:false},{name:"d3-geo",version:"3.1.1",path:"dist/d3-geo.min.js",async:false}],i18n:{"zh-TW":{town:"鄉鎮",village:"村里",value:"數值",size:"大小",category:"分類",proportion:"比例",aggregated:"村里匯總"}}},init:function(t){var e,n,i,r,l,o;e=t.root,n=t.context,i=t.t,r=t.pubsub,l=t.data,o=t.manager;return mod({context:n,t:i,data:l,manager:o,cls:this._instance.block}).then(function(t){return r.fire("init",{mod:t}).then(function(t){return t[0]})})}};svgns="http://www.w3.org/2000/svg";tau=Math.PI*2;mk=function(t,e,n){var i;i=document.createElementNS(svgns,e);if(n){i.setAttribute("class",n)}t.appendChild(i);return i};ringArea=function(t){var e,n,i,r;e=0;for(n=0,i=t.length-1;n<i;++n){r=n;e+=t[r][0]*t[r+1][1]-t[r+1][0]*t[r][1]}return e/2};ringCentroid=function(t){var e,n,i,r,l,o,a,s,u,c,f,h;e=[0,0,0],n=e[0],i=e[1],r=e[2];for(l=0,o=t.length-1;l<o;++l){a=l;e=t[a],s=e[0],u=e[1];e=t[a+1],c=e[0],f=e[1];h=s*f-c*u;n+=h;i+=(s+c)*h;r+=(u+f)*h}if(!n){return(t[0]||[0,0]).slice()}return[i/(3*n),r/(3*n)]};metrics=function(t){var e,n,i,r,l,o,a,s,u,c,f,h,d,g,p,m;e=[0,0,0,null,0],n=e[0],i=e[1],r=e[2],l=e[3],o=e[4];for(a=0,s=t.length;a<s;++a){u=t[a];for(c=0,f=u.length;c<f;++c){h=c;d=u[c];if(d.length<4){continue}g=Math.abs(ringArea(d));p=ringCentroid(d);m=h===0?g:-g;n+=m;i+=p[0]*m;r+=p[1]*m;if(h===0&&g>o){e=[p,g],l=e[0],o=e[1]}}}l=l||[0,0];return{area:n>0?n:0,c:n>0?[i/n,r/n]:l,label:l}};clone=function(t){return t.map(function(t){return t.map(function(t){return t.map(function(t){return[t[0],t[1]]})})})};eachPoint=function(t,e){var n,i,r,l,o,a,s,u,c,f,h,d=[];for(n=0,i=t.length;n<i;++n){r=t[n];l=[];for(o=0,a=r.length;o<a;++o){s=r[o];u=[];for(c=0,f=s.length;c<f;++c){h=s[c];u.push(e(h))}l.push(u)}d.push(l)}return d};cartogram=function(t,e,n){var i,r,l,o,a,s,u,c,f,h,d,g,p,m,b,v,y,w,x,k,M,_,A,j;n==null&&(n=15);i=t.filter(function(t){return t.v!=null&&isFinite(t.v)&&metrics(t.polys).area>0});if(i.length<2){return}r=[];for(l=0,o=e.length;l<o;++l){a=e[l];eachPoint(a,P)}for(l=0;l<n;++l){s=l;u=i.map(z);c=u.reduce(S,0);f=u.reduce(O,0);if(!(f>0)){return}h=0;d=u.map(I);g=1/(1+h/d.length);for(p=0,o=r.length;p<o;++p){m=r[p];b=[0,0],v=b[0],y=b[1];for(w=0,x=d.length;w<x;++w){k=d[w];M=m[0]-k.x;_=m[1]-k.y;A=Math.sqrt(M*M+_*_);if(A<1e-9){continue}j=A>k.r?k.f*k.r/A:k.f*(A*A/(k.r*k.r))*(4-3*A/k.r);v+=j*M/A;y+=j*_/A}m[0]+=g*v;m[1]+=g*y}}function P(t){return r.push(t)}function z(t){var e;return{m:metrics(t.polys),v:(e=t.v)>0?e:0}}function S(t,e){return t+e.m.area}function O(t,e){return t+e.v}function I(t){var e,n,i,r,l,o,a;e=t.m,n=t.v;i=(r=c*n/f)>(l=c*1e-4)?r:l;o=(r=e.area)>1e-9?r:1e-9;h+=(o>i?o:i)/(o<i?o:i);a=Math.sqrt(o/Math.PI);return{x:e.c[0],y:e.c[1],r:a,f:Math.sqrt(i/Math.PI)-a}}};relax=function(t,e,n){var i,r,l,o,a,s,u,c,f,h,d,g,p,m,b,v,y,w,x,k,M;e==null&&(e=0);n==null&&(n=160);for(i=0,r=n+120;i<r;++i){l=i;o=l<n?.12*(1-l/n):0;if(o){for(a=0,s=t.length;a<s;++a){u=t[a];u.x+=(u.tx-u.x)*o;u.y+=(u.ty-u.y)*o}}for(a=0,c=t.length;a<c;++a){f=a;h=t[f];for(d=f+1,g=t.length;d<g;++d){p=d;m=t[p];b=m.x-h.x;v=m.y-h.y;y=h.r+m.r+e;if(Math.abs(b)>=y||Math.abs(v)>=y){continue}w=Math.sqrt(b*b+v*v);if(w>=y){continue}if(w<1e-6){x=[.001*(p-f),0,.001*(p-f)],b=x[0],v=x[1],w=x[2]}k=(y-w)/w;M=m.r*m.r/(h.r*h.r+m.r*m.r);h.x-=b*k*M;h.y-=v*k*M;m.x+=b*k*(1-M);m.y+=v*k*(1-M)}}}return t};pieArcs=function(i,t){var r,l,o,e,n,a,s,u,c,f,h,d,g,p,m,b,v;i=i.map(function(t){if(isFinite(t)&&t>0){return t}else{return 0}});r=i.reduce(function(t,e){return t+e},0);if(!(r>0)){return[]}l=i.length;if(t==="desc"||l<2){o=0;return function(){var t,e,n=[];for(t=0,e=l;t<e;++t){n.push(t)}return n}().sort(function(t,e){return i[e]-i[t]||t-e}).map(function(t){var e,n;e=tau*i[t]/r;n={i:t,a0:o,a1:o+e};o+=e;return n})}n=[];for(a=2;a<l;++a){s=a;n.push(s)}e=n;u=e.slice(0,Math.ceil(e.length/2));c=e.slice(u.length);f=u.concat([1],c,[0]);h=function(t){if(t===0){return tau*3/4}else if(t===1){return tau/4}else if(in$(t,u)){return 0}else{return tau/2}};d=0;g=[0,0],p=g[0],m=g[1];b=f.map(function(t){var e,n;e=tau*i[t]/r;n=h(t)-(d+e/2);p+=Math.cos(n);m+=Math.sin(n);d+=e;return e});v=Math.atan2(m,p);o=v;return f.map(function(t,e){var n;n={i:t,a0:o,a1:o+b[e]};o+=b[e];return n})};wedge=function(e,n,i,t,r){var l,o,a,s,u,c;if(r-t>=tau-1e-6){return"M"+e+","+(n-i)+"A"+i+","+i+" 0 1 1 "+e+","+(n+i)+"A"+i+","+i+" 0 1 1 "+e+","+(n-i)+"Z"}l=function(t){return[e+i*Math.sin(t),n-i*Math.cos(t)]};o=l(t),a=o[0],s=o[1];o=l(r),u=o[0],c=o[1];return"M"+e+","+n+"L"+a+","+s+"A"+i+","+i+" 0 "+(r-t>Math.PI?1:0)+" 1 "+u+","+c+" Z"};toRgb=function(t,e){var n,i,r,l;t=t.value||t;if(typeof t==="string"&&(n=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(t.trim()))){i=n[1];if(i.length===3){i=i.split("").map(function(t){return t+t}).join("")}return[0,1,2].map(function(t){return parseInt(i.substr(t*2,2),16)})}try{r=e.rgb(t);return[r.r,r.g,r.b].map(function(t){return Math.round(t)})}catch(t){l=t;return[128,128,128]}};rgbStr=function(t,i){i==null&&(i=1);return"rgb("+t.map(function(t){var e,n;return(e=(n=Math.round(t*i))>0?n:0)<255?e:255}).join(",")+")"};ramp=function(o){return function(t){var e,n,i,r,l;if(!(o&&o.length)){return[200,200,200]}if(o.length===1){return o[0]}t=(e=(n=isNaN(t)?0:t)>0?n:0)<1?e:1;i=t*(o.length-1);r=(e=Math.floor(i))<(n=o.length-2)?e:n;l=i-r;return[0,1,2].map(function(t){return o[r][t]+(o[r+1][t]-o[r][t])*l})}};rank=function(u){return function(t){var e,n,i,r,l,o,a,s;e=u.length;if(e<2){return.5}if(t<=u[0]){return 0}if(t>=u[e-1]){return 1}n=[0,e-1],i=n[0],r=n[1];while(r-i>1){l=i+r>>1;if(u[l]<=t){i=l}else{r=l}}o=i;while(o>0&&u[o-1]===u[i]){o--}a=i;while(a<e-1&&u[a+1]===u[i]){a++}s=u[i]===t?(o+a)/2:i+(t-u[i])/(u[i+1]-u[i]||1);return s/(e-1)}};unrank=function(a){return function(t){var e,n,i,r,l,o;e=a.length;if(!e){return 0}n=((i=t>0?t:0)<1?i:1)*(e-1);r=(i=(l=Math.floor(n))<(o=e-2)?l:o)>0?i:0;if(e===1){return a[0]}return a[r]+(a[r+1]-a[r])*(n-r)}};palettes={sequential:{name:"orange",colors:["#fff5eb","#fdd0a2","#fd8d3c","#d94801","#7f2704"]},diverging:{name:"rdbu",colors:["#2166ac","#67a9cf","#f7f7f7","#ef8a62","#b2182b"]}};townWords=["全區","全部","總計","合計","小計","全鄉","全鎮","全市","全區合計","total","all"];mod=function(t){var e,n,i,O,I,q,qt,$,r,L,ft;e=t.context,n=t.t,i=t.data,O=t.manager,I=t.cls;q=e.chart,qt=e.ldcolor,$=e.topojson;r=q.utils,L=r.format,ft=r.anim.join;n=n||function(t){return t};return Promise.resolve().then(function(){var e,S,t,n;e=i.level||"county/臺北市";S=e.split("/")[1]||"";t="2.5.0";n=[{name:"pdmaptw",version:t,path:"index.min.js",async:false},{name:"pdmaptw",version:t,path:e+".village.map.js",async:false}];return O.rescope.load(n,I.context()).then(function(t){var z;z=t.pdmaptw;return z.get(e+"/village").then(function(t){var E,e,R,a,n,i,r,l,o,s,u,c,f,h,d,g,p,m,b,v,y,w,x,k,M,C,W,_,A;E=function(t){return z.normalize((t!=null?t:"")+"").trim()};e=E(S);R=function(t){return E(t).replace(e,"")};a=z.projection();n=function(t,l,e){var n,o;if(!(t&&t.topo.objects[e])){return[]}n=t.topo,o=t.meta;return $.feature(n,n.objects[e]).features.map(function(t){var e,n,i,r;e=t.properties;n=t.geometry||{};i=n.type==="Polygon"?[n.coordinates]:n.type==="MultiPolygon"?n.coordinates:[];i=i.map(function(t){return t.map(function(t){return t.map(function(t){return a(t)})})});r=function(t){if(e[t]!=null){return E(o.name[e[t]])}else{return""}};return{code:e.code,level:l,town:r("t"),village:r("v"),polys:i,tcode:(e.code+"").substring(0,8)}})};i=n(t,"town","town");r=n(t,"village","pdmaptw");l=i.length?(o=$.merge(t.topo,t.topo.objects.town.geometries),(o.type==="Polygon"?[o.coordinates]:o.coordinates).map(function(t){return t.map(function(t){return t.map(function(t){return a(t)})})})):[];s=[Infinity,Infinity,-Infinity,-Infinity],u=s[0],c=s[1],f=s[2],h=s[3];for(d=0,g=i.length;d<g;++d){p=i[d];eachPoint(p.polys,j)}m=1e3/(f-u||1);for(d=0,g=(s=i.concat(r,[{polys:l}])).length;d<g;++d){b=s[d];eachPoint(b.polys,P)}v=1e3;y=(h-c)*m;for(d=0,g=(s=i.concat(r)).length;d<g;++d){b=s[d];import$(b,metrics(b.polys))}w={};for(d=0,g=r.length;d<g;++d){x=r[d];(w[k=x.tcode]||(w[k]=[])).push(x)}M={};for(d=0,g=(s=i.concat(r)).length;d<g;++d){b=s[d];M[b.code]=b}C={};for(d=0,g=i.length;d<g;++d){p=i[d];C[p.town]=p}W={};for(d=0,g=r.length;d<g;++d){x=r[d];W[x.tcode+"/"+x.village]=x}_={towns:i,villages:r,outline:l,W:v,H:y,villOf:w,feat:M};return{sample:function(){var t;t=O.getUrl({ns:I.ns,name:I.name,version:I.version,path:"sample/"+S+".json",type:"json"});return fetch(t).then(function(t){if(t.ok){return t.json()}else{return Promise.reject(new Error(t.status+""))}})["catch"](function(t){console.warn("[twmapadv] sample data for "+S+" not found:",t);return{head:[],units:{},rows:[]}}).then(function(t){var e,n,i;e=t.head,n=t.units,i=t.rows;return{raw:i.map(function(n){return Object.fromEntries(e.map(function(t,e){return[t,n[e]]}))}),binding:{town:{key:"鄉鎮"},village:{key:"村里"},value:{key:"人口密度",unit:n.人口密度},size:{key:"人口",unit:n.人口},cat:{key:"高齡分級"},parts:[{key:"男",unit:n.男},{key:"女",unit:n.女}]}}})},config:(s=q.utils.config.from({preset:"default",tip:"tip"}),s.mode={type:"choice",values:["map","cartogram","bubble"],default:"map"},s.colorBy={type:"choice",values:["auto","value","cat"],default:"auto"},s.heat={mode:{type:"choice",values:["sequential","diverging"],default:"sequential"},scale:{type:"choice",values:["linear","log","pow","quantile"],default:"linear"},exponent:{type:"number",default:.5,min:.1,max:5,step:.1},center:{mode:{type:"choice",values:["median","mean","manual"],default:"median"},value:{type:"number",default:0}},symmetric:{type:"boolean",default:true},steps:{type:"number",default:0,min:0,max:12,step:1},sequential:{type:"palette",default:palettes.sequential},diverging:{type:"palette",default:palettes.diverging},empty:{type:"color",default:"#e5e5e5"}},s.legend=(A=import$({},q.utils.config.preset.legend),A.format={type:"format",default:".3s"},A),s.village={mode:{type:"choice",values:["click","all","none"],default:"click"},aggregate:{type:"choice",values:["sum","mean","none"],default:"sum"},domain:{type:"choice",values:["level","shared"],default:"level"},zoom:{type:"boolean",default:false}},s.border={color:{type:"color",default:"#fff"},width:{type:"number",default:1,min:0,max:20,step:.1},linejoin:{type:"choice",values:["round","bevel","miter"],default:"round"},village:{color:{type:"color",default:"#fff"},width:{type:"number",default:.4,min:0,max:20,step:.1}}},s.extrude={enabled:{type:"boolean",default:false},height:{type:"number",default:.25,min:0,max:2,step:.01},tilt:{type:"number",default:55,min:0,max:85,step:1},angle:{type:"number",default:-20,min:-180,max:180,step:1},rotate:{type:"choice",values:["drag","auto","both","none"],default:"drag"},speed:{type:"number",default:12,min:-180,max:180,step:1},base:{enabled:{type:"boolean",default:true},color:{type:"color",default:"#d8d8d8"}},shade:{type:"number",default:.25,min:0,max:1,step:.01}},s.cartogram={iteration:{type:"number",default:15,min:1,max:60,step:1}},s.bubble={scale:{type:"number",default:1,min:.1,max:4,step:.05},overlap:{type:"boolean",default:false},padding:{type:"number",default:1,min:0,max:20,step:.5},leader:{type:"boolean",default:true},leaderColor:{type:"color",default:"#999"},basemap:{type:"boolean",default:true},basemapColor:{type:"color",default:"#eeeeee"},stroke:{type:"color",default:"#fff"},strokeWidth:{type:"number",default:.5,min:0,max:10,step:.1},pie:{type:"choice",values:["side","desc","none"],default:"side"}},s.label={enabled:{type:"boolean",default:true},village:{type:"boolean",default:false},font:q.utils.config.from({preset:"font"}),color:{type:"color",default:"#222"},halo:{type:"color",default:"#fff"},haloWidth:{type:"number",default:2,min:0,max:10,step:.5}},s.filterLevel={type:"choice",values:["town","village"],default:"town"},s),dimension:{town:{type:"N",name:"town",priority:1},village:{type:"N",name:"village",priority:2},value:{type:"R",name:"value",priority:3},size:{type:"R",name:"size",priority:4},cat:{type:"C",name:"category",priority:5},parts:{type:"R",name:"proportion",priority:6,multiple:true}},init:function(){var e,t,n,i,r,l,o,a,s,u,c,f,h=this;this.geo=_;this.expanded={};this.angle=null;this.tint=e=new q.utils.tint;this.g=Object.fromEntries(["view","legend","scale"].map(function(t){return[t,h.layout.getGroup(t)]}));import$(this.g,Object.fromEntries(["bg","base","units","solid","outline","leader","bubble","label"].map(function(t){return[t,mk(h.g.view,"g",t)]})));this.pool=[];this._t3=document.createElementNS(svgns,"g");this.g.bg=mk(this.g.bg,"rect");this.clip=mk(mk(mk(this.g.view,"defs"),"clipPath"),"rect");this.clip.parentNode.setAttribute("id","tmap-clip-"+Math.random().toString(36).substring(2));this.g.bg.setAttribute("fill","transparent");this.node={};for(t=0,i=(n=_.towns.concat(_.villages)).length;t<i;++t){r=n[t];l=mk(this.g.units,"g","unit "+r.level);l.__data__={code:r.code,_raw:null};o=mk(l,"path","top");o.__data__=l.__data__;a=mk(this.g.bubble,"g","bubble "+r.level);a.__data__=l.__data__;s=mk(this.g.label,"text");s.setAttribute("text-anchor","middle");s.setAttribute("dominant-baseline","central");s.setAttribute("paint-order","stroke");s.style.pointerEvents="none";u=mk(this.g.leader,"line");u.setAttribute("stroke-dasharray","2 2");this.node[r.code]={g:l,top:o,bubble:a,label:s,line:u}}this.base={top:mk(this.g.base,"path"),wall:mk(this.g.base,"path")};this.outline={};for(t=0,i=(n=_.towns).length;t<i;++t){c=n[t];this.outline[c.code]=mk(this.g.outline,"path");this.outline[c.code].setAttribute("fill","none")}this.g.outline.style.pointerEvents="none";this.g.leader.style.pointerEvents="none";this.legend=new q.utils.legend({root:this.root,name:"legend",layout:this.layout,shape:function(t){return this.setAttribute("fill",e.get(t.key))}});this.legend.on("select",function(){h.bind();h.resize();return h.render()});this.tip=new q.utils.tip({root:this.root,accessor:function(t){var e,n,i;e=t.evt;if(!(e.target&&(n=e.target.__data__)&&n.code&&(i=h.geo.feat[n.code]))){return null}return h.local.tip(i)},range:function(){return h.layout.getNode("view").getBoundingClientRect()}});n=this.tip.tip.style;n.maxWidth="16em";n.whiteSpace="pre-line";f=null;this.g.view.addEventListener("pointerdown",function(t){return f=h.drag={x:t.clientX,moved:false,angle:h.local.angle()}});this.root.addEventListener("pointermove",function(t){var e,n;if(!f){return}if(!t.buttons){return f=h.drag=null}e=t.clientX-f.x;if(Math.abs(e)>3){f.moved=true}if(!(f.moved&&h.local.is3d()&&((n=h.cfg.extrude.rotate)==="drag"||n==="both"))){return}h.angle=f.angle-e*.5;return h.local.draw(true)});this.root.addEventListener("pointerup",function(){h.drag=null;return setTimeout(function(){return f=null},0)});return this.g.view.addEventListener("click",function(t){var e;if(f&&f.moved){return}e=(t.target||{}).__data__;if(e&&e.code){return h.local.click(t,h.geo.feat[e.code])}else{return h.local.reset()}})},destroy:function(){this.tip.destroy();return this.legend.destroy()},filter:function(t,e){},parse:function(){var n,t,e,i,r,l,o,a,s,u,c,f,h,d,g,p,m,b,v,y,w,x,k,M=[],_=this;n=function(t){if(t!=null&&t!==""&&!isNaN(+t)){return+t}else{return undefined}};this.rec={};t=function(t){var e;e=Array.isArray(t.parts)?t.parts:t.parts!=null?[t.parts]:[];return{value:n(t.value),size:n(t.size),cat:t.cat,parts:e.map(n),row:t}};for(e=0,r=(i=this.data).length;e<r;++e){l=i[e];o=((l.town!=null?l.town:"")+"").trim();a=((l.village!=null?l.village:"")+"").trim();s=this.geo.feat[o]||C[R(o)];if(s&&s.level==="village"){this.rec[s.code]=(u=t(l),u.keys=[l.town],u);continue}if(!s&&this.geo.feat[a]){s=this.geo.feat[this.geo.feat[a].tcode]}if(!s||s.level!=="town"){continue}if(!a||in$(a.toLowerCase(),townWords)){this.rec[s.code]=(u=t(l),u.keys=[l.town],u)}else{c=this.geo.feat[a]||W[s.code+"/"+E(a)];if(c&&c.level==="village"){this.rec[c.code]=(u=t(l),u.keys=[l.town],u.vname=l.village,u)}}}f=this.cfg.village.aggregate;for(e=0,r=(i=this.geo.towns).length;e<r;++e){o=i[e];if(this.rec[o.code]||f==="none"){continue}h=(this.geo.villOf[o.code]||[]).map(A).filter(j);if(!h.length){continue}d=P;g={};for(p=0,m=h.length;p<m;++p){b=h[p];if(b.cat!=null){g[b.cat]=(g[b.cat]||0)+1}}v=z().sort(S)[0];w=Math.max.apply(null,h.map(O));x=I().map(q);k=Array.from(new Set([].concat.apply([],h.map($))));M.push(this.rec[o.code]={value:d("value"),size:d("size"),cat:v,parts:x,keys:k,agg:true})}return M;function A(t){return _.rec[t.code]}function j(t){return t}function P(e){var t,n;t=h.map(function(t){return t[e]}).filter(function(t){return t!=null});if(!t.length){return undefined}n=t.reduce(function(t,e){return t+e},0);if(f==="mean"){return n/t.length}else{return n}}function z(){var t=[];for(y in g){t.push(y)}return t}function S(t,e){return g[e]-g[t]}function O(t){return t.parts.length}function I(){var t,e,n=[];for(t=0,e=w;t<e;++t){n.push(t)}return n}function q(e){var t,n;t=h.map(function(t){return t.parts[e]}).filter(function(t){return t!=null});if(!t.length){return undefined}n=t.reduce(function(t,e){return t+e},0);if(f==="mean"){return n/t.length}else{return n}}function $(t){return t.keys}},resize:function(){var t;this.root.querySelector(".pdl-layout").classList.toggle("legend-bottom",this.cfg.legend.position==="bottom");this.tip.toggle(((t=this.cfg).tip||(t.tip={})).enabled!=null?this.cfg.tip.enabled:true);this.legend.config(this.cfg.legend);this.local.prepare();this.legend.update(false);this.layout.update(false);return this.box=this.layout.getBox("view")},render:function(){if(!this.box){return}this.local.draw();this.local.drawScale();this.legend.render();if(this.local.autoRotate()){return this.start()}else{return this.stop()}},tick:function(t,e){e==null&&(e=0);if(!(this.local.autoRotate()&&e)||this.drag&&this.drag.moved){return}this.angle=this.local.angle()+this.cfg.extrude.speed*e/1e3;return this.local.draw(true)},local:{is3d:function(){return this.cfg.extrude.enabled&&this.cfg.mode!=="bubble"},angle:function(){if(this.angle!=null){return this.angle}else{return this.cfg.extrude.angle}},autoRotate:function(){var t;return this.local.is3d()&&((t=this.cfg.extrude.rotate)==="auto"||t==="both")},isPie:function(){return this.cfg.mode==="bubble"&&this.cfg.bubble.pie!=="none"&&Array.isArray(this.binding.parts)&&this.binding.parts.length>=2},colorBy:function(){if(this.cfg.colorBy==="cat"){return this.binding.cat?"cat":"value"}if(this.cfg.colorBy==="value"){return"value"}if(this.binding.value){return"value"}else if(this.binding.cat){return"cat"}else{return"value"}},expanded:function(t){var e;if(!(this.geo.villOf[t.code]||[]).length){return false}e=this.cfg.village.mode;return e==="all"||e==="click"&&this.expanded[t.code]},units:function(){var t,e,n,i,r;t=[];for(e=0,i=(n=this.geo.towns).length;e<i;++e){r=n[e];if(this.local.expanded(r)){t=t.concat(this.geo.villOf[r.code])}else{t.push(r)}}return t.filter(function(t){return t.area>0})},prepare:function(){var e,t,n,i,r,l,o,a,s,u,c,f,h,d,g,p,m,b=this;e=function(t){if(b.cfg.village.domain==="shared"){return"all"}else{return t.level}};t={};for(n in i=this.rec){r=i[n];l=this.geo.feat[n];o=t[a=e(l)]||(t[a]=[]);o.push(r)}this.dom={};for(s in t){u=t[s];c=u.map(v).filter(y).sort(w);f=u.map(x).filter(k);this.dom[s]={value:c,scale:this.local.heat(c),smax:f.length?Math.max.apply(null,f.map(M)):0};h=f.reduce(_,0);d=this.geo.W*this.geo.H*.3;this.dom[s].rmax=h?Math.sqrt(d/(Math.PI*h)):0}this.domOf=function(t){return b.dom[e(t)]||{value:[],scale:null,smax:0,rmax:0}};g=this.local.colorBy();this.tint.reset();this.tint.mode(q.utils.tint.mode.ordinal);this.tint.set(this.cfg.palette);if(this.local.isPie()){this.parts=this.binding.parts.map(function(t,e){return{key:t.name||t.key||e+1+"",text:t.name||t.key||e+1+""}});this.legend.data(this.parts.map(function(t,e){return t.value=-e,t}))}else if(g==="cat"){p=[];for(n in i=this.rec){r=i[n];if(r.cat!=null&&!in$(r.cat,p)){p.push(r.cat)}}p.sort();this.legend.data(p.map(function(t){return{key:t,text:t+""}}))}else{this.legend.data([])}this.showScale=!this.local.isPie()&&g==="value"&&this.binding.value!=null&&this.cfg.legend.enabled!==false;m=this.layout.getNode("scale");return m.style.display=this.showScale?"":"none";function v(t){return t.value}function y(t){return t!=null&&isFinite(t)}function w(t,e){return t-e}function x(t){if(t.size!=null){return t.size}else{return t.value}}function k(t){return t!=null&&isFinite(t)}function M(t){return Math.abs(t)}function _(t,e){return t+Math.abs(e)/(b.dom[s].smax||1)}},heat:function(t){var e,n,r,i,l,o,a,s,u,c,f,h,d,g,p,m,b,v,y;if(!t.length){return null}e=this.cfg.heat;n=e.exponent||.5;r=function(){switch(e.scale){case"log":return function(t){return(t<0?-1:1)*Math.log10(1+Math.abs(t))};case"pow":return function(t){if(t<0){return-Math.pow(-t,n)}else{return Math.pow(t,n)}};case"quantile":return rank(t);default:return function(t){return t}}}();i=[t[0],t[t.length-1]],l=i[0],o=i[1];a=e.mode==="diverging";s=!a?null:e.center.mode==="manual"?e.center.value:e.center.mode==="mean"?t.reduce(function(t,e){return t+e},0)/t.length:(u=t.length/2,t.length%2?t[Math.floor(u)]:(t[u-1]+t[u])/2);if(a&&e.symmetric){c=Math.max(Math.abs(r(o)-r(s)),Math.abs(r(s)-r(l)));i=[r(s)-c,r(s)+c],f=i[0],h=i[1]}else{i=[r(l),r(o)],f=i[0],h=i[1]}d=a?r(s):null;g=Math.round(e.steps||0);p=function(t){var e,n,i;e=r(t);n=!a?(e-f)/(h-f||1):e<d?.5*(e-f)/(d-f||1):.5+.5*(e-d)/(h-d||1);n=(i=n>0?n:0)<1?i:1;if(g>1){n=Math.min(g-1,Math.floor(n*g))/(g-1)}return n};m=a?e.diverging:e.sequential;b=(m&&m.colors&&m.colors.length&&m.colors||palettes[a?"diverging":"sequential"].colors).map(function(t){return toRgb(t,qt)});v=ramp(b);y=function(){switch(e.scale){case"log":return function(t){return(t<0?-1:1)*(Math.pow(10,Math.abs(t))-1)};case"pow":return function(t){return(t<0?-1:1)*Math.pow(Math.abs(t),1/n)};case"quantile":return unrank(t);default:return function(t){return t}}}();return{t:p,lo:l,hi:o,center:s,color:v,div:a,inv:y,tlo:f,thi:h,tc:d}},color:function(t){var e,n;e=this.rec[t.code];if(!e){return null}if(this.local.colorBy()==="cat"){return e.cat!=null&&this.legend.isVisible(e.cat)?toRgb(qt.web(this.tint.get(e.cat)),qt):null}n=this.domOf(t).scale;if(!(n&&e.value!=null&&isFinite(e.value))){return null}return n.color(n.t(e.value))},height:function(t){var e,n,i,r,l,o,a;e=this.rec[t.code];if(!e){return 0}n=e.value!=null?e.value:e.size;i=this.domOf(t).value;if(!(n!=null&&i.length)){return 0}r=(l=i[0])<0?l:0;o=i[i.length-1];if(o<=r){return 1}return(l=(a=(n-r)/(o-r))>0?a:0)<1?l:1},ratio:function(t,e,n){var i;i=this.rec[t.code];if(!(i&&i.row&&i.row.subset)){return null}e=e||(this.binding.size?"size":"value");return this.subset.ratio(i.row,e,n)},picked:function(t){var e,n,i,r,l,o,a,s;e=(n=((this.cfg.common||{}).subset||{}).opacity)!=null?n:.2;i=this.rec[t.code]||{};r=this.subset.mode();if((r==="dim"||r==="partial"&&this.cfg.mode!=="bubble")&&this.local.ratio(t)===0){return e}l=t.level==="village"?this.rec[t.tcode]||{}:i;o=((this.binding.town||{}).filter||{}).value;a=((this.binding.village||{}).filter||{}).value;s=i.keys||l.keys||[];if(o&&!s.some(function(t){return in$(t,o)})){return e}if(a&&t.level==="village"&&!(i.vname!=null&&in$(i.vname,a))){return e}if(this.local.colorBy()==="cat"&&!this.local.isPie()&&i.cat!=null&&!this.legend.isSelected(i.cat)){return this.legend.opacity()}return 1},shape:function(){var t,e,n,i,r,l,o,a,s,u,c,f,h,d,g,p,m=this;t=this.cfg.mode;e=this.cfg.village.mode==="all";n=function(t){var e,n;e=m.rec[t.code];if(!e){return undefined}n=e.size!=null?e.size:e.value;if(n!=null){return Math.abs(n)}else{return undefined}};i=[t,e,this.cfg.cartogram.iteration].join("/")+(t==="cartogram"?"/"+this.geo.towns.concat(this.geo.villages).map(n).join(","):"");if(this._shape&&this._shape.key===i){return this._shape}r={};for(l=0,a=(o=this.geo.towns.concat(this.geo.villages)).length;l<a;++l){s=o[l];r[s.code]=s.polys}u=this.geo.outline;if(t==="cartogram"){r={};for(l=0,a=(o=this.geo.towns.concat(this.geo.villages)).length;l<a;++l){s=o[l];r[s.code]=clone(s.polys)}u=clone(this.geo.outline);c=e&&this.geo.villages.some(function(t){return m.rec[t.code]})?this.geo.villages:this.geo.towns;f=c.map(function(t){return{polys:r[t.code],v:n(t)}});h=[u].concat(this.geo.towns.concat(this.geo.villages).map(function(t){return r[t.code]}));cartogram(f,h,this.cfg.cartogram.iteration)}d={};for(g in r){p=r[g];d[g]=t==="cartogram"?metrics(p):this.geo.feat[g]}return this._shape={key:i,polys:r,outline:u,ms:d}},focus:function(){var t,e=this;if(!(this.cfg.village.zoom&&this.cfg.village.mode==="click")){return null}t=this.geo.towns.filter(function(t){return e.local.expanded(t)});if(t.length){return t}else{return null}},viewParam:function(){var t,e,n,i,r,l,o,a,s,u,c,f,h,d,g,p,m,b,v,y,w,x;t=this.box;e=10;n=this.local.is3d();i=this.geo.W/2;r=this.geo.H/2;l=[this.geo.W,this.geo.H],o=l[0],a=l[1];s=this.local.focus();u=this.geo.outline;if(s){c=this.local.shape();u=[].concat.apply([],s.map(function(t){return c.polys[t.code]}));l=[Infinity,Infinity,-Infinity,-Infinity],f=l[0],h=l[1],d=l[2],g=l[3];eachPoint(u,function(t){var e;f=f<(e=t[0])?f:e;h=h<(e=t[1])?h:e;d=d>(e=t[0])?d:e;return g=g>(e=t[1])?g:e});l=[(f+d)/2,(h+g)/2,d-f||1,g-h||1],i=l[0],r=l[1],o=l[2],a=l[3]}this.clip.setAttribute("width",t.width);this.clip.setAttribute("height",t.height);if(s){this.g.view.setAttribute("clip-path","url(#"+this.clip.parentNode.id+")")}else{this.g.view.removeAttribute("clip-path")}if(!n){p=(l=Math.min((t.width-2*e)/o,(t.height-2*e)/a))>.01?l:.01;return{is3d:n,cx:i,cy:r,s:p,ox:t.width/2-i*p,oy:t.height/2-r*p}}m=this.cfg.extrude.tilt*Math.PI/180;l=[Math.cos(m),Math.sin(m)],b=l[0],v=l[1];y=0;eachPoint(u,function(t){var e;return y=y>(e=Math.hypot(t[0]-i,t[1]-r))?y:e});w=this.cfg.extrude.height*this.geo.W;x=this.geo.W*.015;p=(l=Math.min((t.width-2*e)/(2*y),(t.height-2*e)/(2*y*b+(w+x)*v)))>.01?l:.01;return{is3d:n,cx:i,cy:r,s:p,hmax:w,thick:x,ox:t.width/2,oy:t.height/2+(w-x)*v*p/2}},mkview:function(t){var n,i,r,l,o,e,a,s,u,c,f,h,d,g,p;n=t.cx,i=t.cy,r=t.s,l=t.ox,o=t.oy;if(!t.is3d){return e=import$({},t),e.pt=function(t,e){return[l+t*r,o+e*r]},e}a=this.local.angle()*Math.PI/180;s=this.cfg.extrude.tilt*Math.PI/180;e=[Math.cos(a),Math.sin(a),Math.cos(s),Math.sin(s)],u=e[0],c=e[1],f=e[2],h=e[3];d=function(t,e){return[(t-n)*u-(e-i)*c,(t-n)*c+(e-i)*u]};g=function(t,e,n){n==null&&(n=0);return[l+t*r,o+e*f*r-n*h*r]};p=function(t,e,n){var i;n==null&&(n=0);i=d(t,e);return g(i[0],i[1],n)};return e=import$({},t),e.rot=d,e.prj=g,e.pt=p,e},view:function(){return this.local.mkview(this.local.viewParam())},draw:function(t){var i,r,l,e,C,o,n,a,s,W,u,c,f,h,d,g,p,m,b,v,y,w,L,x,N,F,B,k,M,_,A,j,P,z,S,O,I,Z,H,G,T,q,V,X,$,J,K,U,E,D,R=this;t==null&&(t=false);i=this.cfg;r=this.local.view();l=this.local.shape();e=this.local.units();C=Object.fromEntries(e.map(function(t){return[t.code,true]}));o=i.mode==="bubble";this.g.bg.setAttribute("width",this.box.width);this.g.bg.setAttribute("height",this.box.height);for(n=0,a=e.length;n<a;++n){s=e[n];this.node[s.code].g.__data__._raw=((this.rec[s.code]||{}).row||{})._raw||null}if(r.is3d){return this.local.draw3d(t)}this.s3=null;this.g.solid.style.display="none";this.g.base.style.display="none";W=this.local.isPie();u=t?0:350;c=function(t,e,n){n==null&&(n=u);return R.anim.tween(t,e,{duration:n})};f=this.prev;h=f?f.v:r;d=function(t){return!f||f.is3d||!f.shown[t]};g=function(t){if(f&&f.is3d){return f.h(t)}else{return 0}};p={};m=function(t,e,n){e==null&&(e=0);n==null&&(n=r);return t.map(function(t){return t.map(function(t){if(t.length<2){return""}return"M"+t.slice(0,-1).map(function(t){return n.pt(t[0],t[1],e).map(function(t){return t.toFixed(2)}).join(",")}).join("L")+"Z"}).join("")}).join("")};b=toRgb(i.heat.empty,qt);for(n=0,a=(v=this.geo.towns.concat(this.geo.villages)).length;n<a;++n){s=v[n];y=this.node[s.code];if(!C[s.code]){y.g.style.display="none";y.bubble.style.display="none";y.line.style.display="none";continue}y.g.style.display="";w=l.polys[s.code];L=this.local.color(s);x=this.local.picked(s);N=s.level==="town"?i.border.width:i.border.village.width;F=s.level==="town"?i.border.color:i.border.village.color;B=o?i.bubble.basemap?toRgb(i.bubble.basemapColor,qt):null:L||b;if(o&&!i.bubble.basemap){y.g.style.display="none"}p[s.code]=true;if(d(s.code)){this.anim.interrupt(y.top);y.top.setAttribute("d",m(w,g(s.code),h))}c(y.top,{d:m(w),fill:B?rgbStr(B):"none",stroke:F,"stroke-width":N,"stroke-linejoin":i.border.linejoin,opacity:x})}for(n=0,a=(v=this.geo.towns).length;n<a;++n){k=v[n];M=this.outline[k.code];if(o||!this.local.expanded(k)){M.style.display="none";continue}M.style.display="";p["o:"+k.code]=true;if(d("o:"+k.code)){this.anim.interrupt(M);M.setAttribute("d",m(l.polys[k.code],g(k.code),h))}c(M,{d:m(l.polys[k.code]),stroke:i.border.color,"stroke-width":i.border.width*1.5,"stroke-linejoin":i.border.linejoin})}_=o?this.local.bubbles(e,l):null;for(n=0,a=e.length;n<a;++n){s=e[n];y=this.node[s.code];if(!o){y.bubble.style.display="none";y.line.style.display="none";continue}A=_[s.code];y.bubble.style.display="";v=r.pt(A.x,A.y),j=v[0],P=v[1];z=A.r*r.s;v=r.pt(A.tx,A.ty),S=v[0],O=v[1];x=this.local.picked(s);I=Math.hypot(S-j,O-P);if(i.bubble.leader&&!i.bubble.overlap&&I>z+1){y.line.style.display="";v=[(S-j)/I,(O-P)/I],Z=v[0],H=v[1];c(y.line,{x1:j+Z*z,y1:P+H*z,x2:S,y2:O,stroke:i.bubble.leaderColor,"stroke-width":.8,opacity:x})}else{y.line.style.display="none"}G=this.rec[s.code]||{};T=(G.row||{})._raw||null;q=W?pieArcs((G.parts||[]).map(Q),i.bubble.pie):[];if(!q.length){q=[{i:-1,a0:0,a1:tau}]}V=this.subset.mode()==="partial";X=Y;$=tt;J=et;K=ft({root:y.bubble,tag:"path",cls:"wedge",data:q,key:nt});K.exit.map(it);K.nodes.map(rt);U=!V?[]:q.filter(lt).map(ot);E=ft({root:y.bubble,tag:"path",cls:"subset",data:U,key:at});E.exit.map(st);E.nodes.map(ut);E.nodes.map(ct)}D=function(t,e,n){var i,r;n==null&&(n=0);if(o){i=_[e.code];return t.pt(i.x,i.y)}r=l.ms[e.code];return t.pt(r.label[0],r.label[1],n)};this.local.labels({units:e,dur:u,drawn:p,fresh:d,pos:function(t){if(o&&_[t.code].r*r.s<10){return null}else{return D(r,t)}},start:function(t){return D(h,t,g(t.code))}});return this.prev={is3d:false,v:r,shown:p};function Q(t,e){if(R.legend.isVisible(R.parts[e].key)){return t}else{return 0}}function Y(t){if(t.i>=0){return toRgb(qt.web(R.tint.get(R.parts[t.i].key)),qt)}else{return R.local.color(s)||b}}function tt(t){if(t.i>=0){return R.local.ratio(s,"parts",t.i)}else{return R.local.ratio(s)}}function et(t){return x*(t.i>=0&&!R.legend.isSelected(R.parts[t.i].key)?R.legend.opacity():1)}function nt(t){return t.i}function it(t){R.anim.interrupt(t);return t.remove()}function rt(t){var e,n;e=t.__data__;t.__data__=(e.code=s.code,e._raw=T,e);n=X(e);return c(t,{d:wedge(j,P,z,e.a0,e.a1),fill:rgbStr(V&&$(e)!=null?toRgb(R.subset.color(rgbStr(n)),qt):n),stroke:i.bubble.stroke,"stroke-width":i.bubble.strokeWidth,opacity:J(e)})}function lt(t){return $(t)!=null}function ot(t){return t.k=Math.sqrt($(t)),t}function at(t){return t.i}function st(t){R.anim.interrupt(t);return t.remove()}function ut(t){var e;e=t.__data__;t.setAttribute("pointer-events","none");return c(t,{d:wedge(j,P,z*e.k,e.a0,e.a1),fill:rgbStr(X(e)),opacity:J(e)})}function ct(t){return y.bubble.appendChild(t)}},labels:function(t){var e,n,i,r,l,o,a,s,u,c,f,h,d,g,p,m,b,v,y,w,x=this,k=[];e=t.units,n=t.pos,i=t.start,r=t.dur,l=t.drawn,o=t.fresh,a=t.depth;s=this.cfg;u=s.label.font||{};c=s.mode==="bubble"||s.label.village?[]:this.geo.towns.filter(function(t){return x.local.expanded(t)});f=Object.fromEntries(e.concat(c).map(function(t){return[t.code,true]}));for(h=0,g=(d=this.geo.towns.concat(this.geo.villages)).length;h<g;++h){p=d[h];if(!f[p.code]){this.node[p.code].label.style.display="none"}}m=[];for(h=0,g=(d=e.concat(c)).length;h<g;++h){p=d[h];b=this.node[p.code];v=s.label.enabled&&(p.level==="town"||s.label.village)?n(p):null;if(!v){b.label.style.display="none";continue}m.push(p);b.label.style.display="";l["l:"+p.code]=true;if(o("l:"+p.code)){y=i(p);b.label.setAttribute("x",y[0]);b.label.setAttribute("y",y[1])}b.label.textContent=p.level==="town"?p.town:p.village;b.label.setAttribute("class",u.family?u.family.className||"":"");w=u.size||"1em";this.anim.tween(b.label,{x:v[0],y:v[1],fill:s.label.color,stroke:s.label.halo,"stroke-width":s.label.haloWidth,"font-size":p.level==="village"?"calc("+w+" * 0.7)":w,opacity:this.local.picked(p)},{duration:r})}if(a){m.sort(function(t,e){return a(t)-a(e)})}else{m=m.filter(function(t){return in$(t,c)})}for(h=0,g=m.length;h<g;++h){p=m[h];k.push(this.g.label.appendChild(this.node[p.code].label))}return k},adjacency:function(t){var e,n,i,r,l,o,a,s,u,c,f,h,d,g,p,m,b,v,y,w,x;n=[];for(i in t){n.push(i)}e=n;r=e.join(",")+"/"+this.local.shape().key;if(this._adj&&this._adj.key===r){return this._adj.map}l=function(t,e){if(t[0]<e[0]||t[0]===e[0]&&t[1]<e[1]){return t[0]+","+t[1]+","+e[0]+","+e[1]}else{return e[0]+","+e[1]+","+t[0]+","+t[1]}};o=new Map;for(a=0,s=e.length;a<s;++a){u=e[a];for(c=0,h=(f=t[u]).length;c<h;++c){d=f[c];for(g=0,p=d.length;g<p;++g){m=d[g];for(b=0,v=m.length-1;b<v;++b){y=b;i=l(m[y],m[y+1]);if(w=o.get(i)){w.push(u)}else{o.set(i,[u])}}}}}x={};for(a=0,s=e.length;a<s;++a){u=e[a];x[u]=t[u].map(k)}this._adj={key:r,map:x};return x;function k(t){return t.map(function(i){return function(){var t,e,n=[];for(t=0,e=i.length-1;t<e;++t){n.push(t)}return n}().map(function(t){return(o.get(l(i[t],i[t+1]))||[]).find(function(t){return t!==u})||null})})}},draw3d:function(t){var e,n,i,r,l,s,o,a,u,c,f,h,d,g,p,m,b,v,y,w,x,k,M,_,A,j,P,z,S=this;e=this.cfg;for(n in i=this.node){r=i[n];r.g.style.display="none";r.bubble.style.display="none";r.line.style.display="none"}for(n in i=this.outline){l=i[n];l.style.display="none"}s=this.local.viewParam();o=this.local.shape();a=this.local.units();u=toRgb(e.heat.empty,qt);c=/^#[0-9a-f]{3}([0-9a-f]{3})?$/i.test(((e.background||"")+"").trim())?toRgb(e.background,qt):[255,255,255];f={};for(h=0,d=a.length;h<d;++h){g=a[h];p=this.local.color(g)||u;m=this.local.picked(g);f[g.code]={h:this.local.height(g)*s.hmax,fill:p.map(O),polys:o.polys[g.code]}}this.s3adj=this.local.adjacency(Object.fromEntries(a.map(function(t){return[t.code,o.polys[t.code]]})));this.s3outline=o.outline;b=a.map(function(t){return Math.sqrt(o.ms[t.code].area||0)}).filter(function(t){return t>0}).sort(function(t,e){return t-e});this.s3band=(i=(b[Math.floor(b.length/2)]||this.geo.W)*.35)>(v=this.geo.W/400)?i:v;if(t&&this.s3){return this.local.render3d()}y=this.s3||{};w=this.s3view||s;x=function(t,n){return t.reduce(function(t,e){return t+e[n]},0)/t.length};k={};for(n in f){M=f[n];_=y[n];g=this.geo.feat[n];if(!_){A=g.level==="village"?y[g.tcode]:null;j=g.level==="town"?(this.geo.villOf[n]||[]).map(I).filter(q):[];_=A?{h:A.h,fill:A.fill}:j.length?{h:x(j,"h"),fill:[0,1,2].map($)}:{h:0,fill:M.fill}}P=_.polys&&_.polys!==M.polys&&_.polys.length===M.polys.length&&_.polys.every(E);k[n]={h:_.h,fill:_.fill,polys:P?_.polys:null}}z=function(t,e,n){return t+(e-t)*n};return this.anim.tween(this._t3,{"data-t":function(l){var t,e,o,n,i;S.s3={};for(t in e=f){o=e[t];n=k[t];i=!n.polys||l>=1?o.polys:n.polys.map(r);S.s3[t]={h:z(n.h,o.h,l),fill:o.fill.map(a),polys:i}}S.s3view=import$(import$({},s),Object.fromEntries(["cx","cy","s","ox","oy"].map(function(t){return[t,z(w[t],s[t],l)]})));S.local.render3d();return l;function r(t,r){return t.map(function(t,i){return t.map(function(t,e){var n;n=o.polys[r][i][e];return[z(t[0],n[0],l),z(t[1],n[1],l)]})})}function a(t,e){return z(n.fill[e],t,l)}}},{duration:t?0:350});function O(t,e){return t*m+c[e]*(1-m)}function I(t){return y[t.code]}function q(t){return t}function $(e){return x(j.map(function(t){return{v:t.fill[e]}}),"v")}function E(t,n){return t.length===M.polys[n].length&&t.every(function(t,e){return t.length===M.polys[n][e].length})}},render3d:function(){var n,t,i,C,W,e,r,l,o,a,L,N,s,u,c,F,f,h,d,g,p,m,b,v,y,B,w,x,k,M,Z,_,H,G,A,T,j,V,P,z,S,O,I,q,$,X,J,K,U,D,Q,Y,tt,et,nt,it,rt,lt,E,ot,at,st,ut,ct,ft,ht,dt,gt,pt,mt,bt,vt,yt,wt,xt,kt,Mt,R,_t,At,jt,Pt=this;n=this.s3;if(!n){return}t=this.cfg;i=this.local.mkview(this.s3view);C=this.s3adj;W=this.local.shape();this.g.solid.style.display="";r=[];for(l in n){r.push(l)}e=r;o=function(t){return t[0].toFixed(2)+","+t[1].toFixed(2)};a=function(t,e){return i.prj(t[0],t[1],e)};L=function(t,e,n,i){return"M"+[a(t,n),a(e,n),a(e,i),a(t,i)].map(o).join("L")+"Z"};N=function(t,e,n){return[t[0]+(e[0]-t[0])*n,t[1]+(e[1]-t[1])*n]};s={};u=[Infinity,-Infinity],c=u[0],F=u[1];for(f=0,h=e.length;f<h;++f){d=e[f];u=[Infinity,-Infinity],g=u[0],p=u[1];m=[];for(b=0,v=(u=n[d].polys).length;b<v;++b){y=u[b];B=[];for(w=0,x=y.length;w<x;++w){k=w;M=y[w];Z=[];for(_=0,H=M.length;_<H;++_){G=M[_];A=i.rot(G[0],G[1]);if(A[1]<g){g=A[1]}if(A[1]>p){p=A[1]}Z.push(A)}B.push({r:Z,sgn:(ringArea(Z)>0?1:-1)*(k>0?-1:1)})}m.push(B)}s[d]={rr:m,lo:g,hi:p};if(g<c){c=g}if(p>F){F=p}}if(t.extrude.base.enabled){T=toRgb(t.extrude.base.color,qt);u=["",""],j=u[0],V=u[1];for(f=0,h=(u=this.s3outline).length;f<h;++f){y=u[f];for(b=0,v=y.length;b<v;++b){k=b;M=y[b];if(M.length<4){continue}m=M.map(zt);j+="M"+m.slice(0,-1).map(St).join("L")+"Z";P=(ringArea(m)>0?1:-1)*(k>0?-1:1);for(w=0,z=m.length-1;w<z;++w){S=w;O=[m[S],m[S+1]],I=O[0],q=O[1];if(P*(I[0]-q[0])>0){V+=L(I,q,-i.thick,0)}}}}this.base.wall.setAttribute("d",V);this.base.wall.setAttribute("fill",rgbStr(T,.8));this.base.top.setAttribute("d",j);this.base.top.setAttribute("fill",rgbStr(T));this.g.base.style.display=""}else{this.g.base.style.display="none"}$=this.s3band;X=e.length?Math.floor((F-c)/$)+1:0;r=[];for(f=0;f<X;++f){K=f;r.push([])}J=r;for(f=0,h=e.length;f<h;++f){d=e[f];A=s[d];for(b=Math.floor((A.lo-c)/$),z=Math.floor((A.hi-c)/$);b<=z;++b){l=b;J[l].push(d)}}U=function(t,e,n){var i,r,l,o,a,s,u,c,f;i=[];for(r=0,l=t.length;r<l;++r){o=r;a=t[r];s=t[(o+1)%t.length];u=[n(a[1]),n(s[1])],c=u[0],f=u[1];if(c){i.push(a)}if(c!==f){i.push(N(a,s,(e-a[1])/(s[1]-a[1])))}}return i};D=function(t,e,n){var i;i=U(t.slice(0,-1),e,function(t){return t>=e});if(i.length<3){return null}i=U(i,n,function(t){return t<=n});if(i.length<3){return null}else{return i}};Q=function(t,e,n,i){var r,l,o,a,s,u;r=e[1]-t[1];if(!r){return t[1]>=n&&t[1]<i?[0,1]:null}l=[(n-t[1])/r,(i-t[1])/r],o=l[0],a=l[1];if(o>a){l=[a,o],o=l[0],a=l[1]}l=[o>0?o:0,a<1?a:1],s=l[0],u=l[1];if(s<u){return[s,u]}else{return null}};Y=this.pool;tt={i:0};et=function(t,e,n){var i,r,l;i=Y[tt.i];if(!i){i=Y[tt.i]=mk(Pt.g.solid,"path");i._a={}}tt.i++;e.d=t;for(r in e){l=e[r];if(i._a[r]!==l){i._a[r]=l;i.setAttribute(r,l)}}return i.__data__=n};nt=1-t.extrude.shade;for(f=0,h=J.length;f<h;++f){l=f;it=J[f];if(!it.length){continue}rt=c+l*$;lt=rt+$;it.sort(Ot);for(b=0,v=it.length;b<v;++b){d=it[b];E=n[d];A=s[d];ot=this.geo.feat[d];at=A.lo>=rt&&A.hi<=lt;u=["","","",""],st=u[0],ut=u[1],j=u[2],ct=u[3];for(w=0,x=(u=A.rr).length;w<x;++w){ft=w;y=u[w];for(_=0,H=y.length;_<H;++_){k=_;O=y[_],M=O.r,P=O.sgn;if(M.length<4){continue}ht=at?M.slice(0,-1):D(M,rt,lt);if(ht){j+="M"+ht.map(It).join("L")+"Z"}dt=C[d][ft][k];for(gt=0,z=M.length-1;gt<z;++gt){S=gt;O=[M[S],M[S+1]],I=O[0],q=O[1];pt=at?[0,1]:Q(I,q,rt,lt);if(!pt){continue}O=[N(I,q,pt[0]),N(I,q,pt[1])],mt=O[0],bt=O[1];ct+="M"+o(a(mt,E.h))+"L"+o(a(bt,E.h));O=[P*(q[1]-I[1]),P*(I[0]-q[0])],vt=O[0],yt=O[1];if(yt<=0){continue}wt=dt[S]&&n[dt[S]]?n[dt[S]].h:0;if(E.h-wt<1e-6){continue}if(vt>0){ut+=L(mt,bt,wt,E.h)}else{st+=L(mt,bt,wt,E.h)}}}}xt=this.node[d].g.__data__;for(w=0,x=(u=[[st,nt],[ut,nt*nt]]).length;w<x;++w){O=u[w],kt=O[0],Mt=O[1];if(kt){R=rgbStr(E.fill,Mt);et(kt,{fill:R,stroke:R,"stroke-width":.5,"stroke-linejoin":"round","pointer-events":"visiblePainted"},xt)}}if(j){R=rgbStr(E.fill);et(j,{fill:R,stroke:R,"stroke-width":.6,"stroke-linejoin":"round","pointer-events":"visiblePainted"},xt)}if(ct){et(ct,{fill:"none",stroke:ot.level==="town"?t.border.color:t.border.village.color,"stroke-width":ot.level==="town"?t.border.width:t.border.village.width,"stroke-linejoin":t.border.linejoin,"pointer-events":"none"},xt)}}}for(f=0,h=(u=Y.splice(tt.i)).length;f<h;++f){_t=u[f];_t.remove()}At=function(t){var e;if(n[t.code]){return n[t.code].h}e=(Pt.geo.villOf[t.code]||[]).map(function(t){return n[t.code]}).filter(function(t){return t});if(e.length){return e.reduce(function(t,e){return t+e.h},0)/e.length}else{return 0}};jt=function(t){var e;e=W.ms[t.code];return i.pt(e.label[0],e.label[1],At(t))};this.local.labels({units:e.map(function(t){return Pt.geo.feat[t]}),dur:0,drawn:{},fresh:function(){return true},pos:jt,start:jt,depth:function(t){var e;e=W.ms[t.code];return i.rot(e.label[0],e.label[1])[1]}});return this.prev={is3d:true,v:i,h:function(t){if(n[t]){return n[t].h}else{return 0}},shown:{}};function zt(t){return i.rot(t[0],t[1])}function St(t){return o(a(t,0))}function Ot(t,e){return n[t].h-n[e].h||s[t].lo+s[t].hi-(s[e].lo+s[e].hi)}function It(t){return o(a(t,E.h))}},bubbles:function(t,e){var o,n,i,r,a=this;o=this.cfg.bubble;n=t.map(function(t){var e,n,i,r,l;e=a.rec[t.code]||{};n=e.size!=null?e.size:e.value;i=a.domOf(t);r=a.geo.feat[t.code];l=n!=null&&i.smax?Math.sqrt(Math.abs(n)/i.smax)*i.rmax*o.scale:0;return{code:t.code,tx:r.c[0],ty:r.c[1],x:r.c[0],y:r.c[1],r:l}});i=JSON.stringify([o.overlap,o.padding,this.box.width].concat(n.map(function(t){return[t.code,t.r.toFixed(3)]})));if(this._bubble&&this._bubble.key===i){return this._bubble.map}r=this.local.view().s;if(!o.overlap){relax(n.filter(function(t){return t.r>0}),o.padding/r)}this._bubble={key:i,map:Object.fromEntries(n.map(function(t){return[t.code,t]}))};return this._bubble.map},drawScale:function(){var i,t,e,n,r,l,o,a,s,u,c,f,h,d,g,p,m,b,v,y,w,x,k,M,_,A,j,P,z,S,O,I,q,$,E,R,C=[];i=this.g.scale;i.textContent="";if(!this.showScale){return}t=this.local.units();e=t.length&&t.every(function(t){return t.level==="village"});n=this.cfg.village.domain!=="shared"&&(e||this.local.focus())?this.geo.villages[0]:this.geo.towns[0];r=this.domOf(n).scale;if(!r){return}l=this.layout.getBox("scale");o=this.cfg.legend.position==="bottom";a=L.from(this.cfg.legend.format||".3s");s=(this.binding.value||{}).unit||"";u="tmap-grad-"+Math.random().toString(36).substring(2);c=mk(i,"defs");f=mk(c,"linearGradient");f.setAttribute("id",u);if(o){f.setAttribute("x2","100%")}else{f.setAttribute("x2","0");f.setAttribute("y1","100%");f.setAttribute("y2","0")}h=Math.round(this.cfg.heat.steps||0);d=h>1?h:24;for(g=0;g<d;++g){p=g;for(m=0,v=(b=h>1?[p/d,(p+1)/d]:[p/(d-1)]).length;m<v;++m){y=b[m];w=mk(f,"stop");w.setAttribute("offset",(y*100).toFixed(2)+"%");x=h>1?p/(h-1):p/(d-1);w.setAttribute("stop-color",rgbStr(r.color(x)))}}k=10;M=o?l.width-20:l.height-30;M=M>20?M:20;_=mk(i,"rect");_.setAttribute("fill","url(#"+u+")");A=r.inv;j=function(t){var e;e=!r.div?r.tlo+(r.thi-r.tlo)*t:t<.5?r.tlo+(r.tc-r.tlo)*t*2:r.tc+(r.thi-r.tc)*(t-.5)*2;return A(e)};P=[0,.5,1];z=function(t,e){var n;n=mk(i,"text");n.textContent=e;n.setAttribute("font-size","0.75em");n.setAttribute("fill","currentColor");if(o){n.setAttribute("x",10+M*t);n.setAttribute("y",k+14);return n.setAttribute("text-anchor","middle")}else{n.setAttribute("x",k+4);n.setAttribute("y",10+M*(1-t));return n.setAttribute("dominant-baseline","central")}};b=o?[10,0,M,k]:[0,10,k,M],S=b[0],O=b[1],I=b[2],q=b[3];for($ in b={x:S,y:O,width:I,height:q}){E=b[$];_.setAttribute($,E)}for(g=0,v=P.length;g<v;++g){R=P[g];C.push(z(R,a(j(R))+""+(R===1?s:"")))}return C},tip:function(t){var e,n,i,r,l,o,a,s,u,c,f,h;e=this.rec[t.code]||{};n=L.from(this.cfg.tip.format||".3s");i=function(t,e){if(t!=null&&isFinite(t)){return n(t)+""+((e||{}).unit||"")}else{return"-"}};r=t.level==="village"?t.village:t.town;l=[];if(this.binding.value){l.push((this.binding.value.name||this.binding.value.key)+": "+i(e.value,this.binding.value))}if(this.binding.size&&this.cfg.mode!=="map"){l.push((this.binding.size.name||this.binding.size.key)+": "+i(e.size,this.binding.size))}if(this.binding.cat&&e.cat!=null){l.push((this.binding.cat.name||this.binding.cat.key)+": "+e.cat)}if(this.local.isPie()){o=(e.parts||[]).reduce(function(t,e){return t+(e||0)},0);for(a=0,u=(s=this.binding.parts).length;a<u;++a){c=a;f=s[a];h=(e.parts||[])[c];l.push((f.name||f.key)+": "+i(h,f)+(o&&h!=null?" ("+(h/o*100).toFixed(1)+"%)":""))}}return{group:t.level==="village"?t.town:"",name:r+(e.agg?" ( "+p("aggregated")+" )":""),value:l[0]||"-",valueAlt:l.slice(1).join("\n")}},click:function(t,e){var i,n,r,l,o,a,s,u;i=t&&t.shiftKey;n=e.level==="town"?e:this.geo.feat[e.tcode];if(e.level==="town"&&this.cfg.village.mode==="click"&&(this.geo.villOf[e.code]||[]).length){if(!i){this.expanded={}}this.expanded[e.code]=true}r=function(e,n){var t;e=(e||[]).slice();n=[].concat(n);t=n.every(function(t){return in$(t,e)});if(i){if(t){return e.filter(function(t){return!in$(t,n)})}else{return Array.from(new Set(e.concat(n)))}}else if(t&&e.length===n.length){return[]}else{return n}};l=((this.binding.town||{}).filter||{}).value;o=((this.binding.village||{}).filter||{}).value;a=this.rec[e.code]||{};s=a.keys||(this.rec[n.code]||{}).keys||[];u={};if(e.level==="village"&&this.cfg.filterLevel==="village"&&this.binding.village&&a.vname!=null){o=r(o,a.vname);l=o.length?Array.from(new Set((l||[]).concat(s))):[];u.village=o.length?{type:"index",value:o}:undefined}else if(s.length){l=r(l,s);u.village=undefined;if(!i&&!l.length){delete this.expanded[n.code]}}else{return this.render()}u.town=l&&l.length?{type:"index",value:l}:undefined;if(!this.binding.town){return this.render()}return this.filter(u,true)},reset:function(){var t,e;t=function(){var t=[];for(e in this.expanded){t.push(e)}return t}.call(this).length||(this.binding.town||{}).filter||(this.binding.village||{}).filter;this.expanded={};if(!t){return}if(this.binding.town){return this.filter({town:undefined,village:undefined},true)}else{return this.render()}}}};function j(t){var e;u=u<(e=t[0])?u:e;c=c<(e=t[1])?c:e;f=f>(e=t[0])?f:e;return h=h>(e=t[1])?h:e}function P(t){t[0]=(t[0]-u)*m;return t[1]=(t[1]-c)*m}})})})};function in$(t,e){var n=-1,i=e.length>>>0;while(++n<i)if(t===e[n])return true;return false}function import$(t,e){var n={}.hasOwnProperty;for(var i in e)if(n.call(e,i))t[i]=e[i];return t}</script><div plug="layout"><div class="pdl-layout"><div data-type="layout"><div class="pdl-cell" data-name="view"></div><div class="pdl-cell" data-name="legend"> </div><div class="pdl-cell" data-name="scale"><div></div></div></div><div data-type="render"></div></div></div></div>
|
|
1
|
+
<div><style type="text/css">.pdl-layout>div[data-type=layout]{display:grid;grid-template-columns:1fr fit-content(8em);grid-template-rows:1fr auto}.pdl-layout>div[data-type=layout]>.pdl-cell[data-name=view]{grid-row:1/span 2}.pdl-layout>div[data-type=layout]>.pdl-cell[data-name=legend]{padding-left:1em}.pdl-layout.legend-bottom>div[data-type=layout]{grid-template-columns:1fr;grid-template-rows:1fr auto auto}.pdl-layout.legend-bottom>div[data-type=layout]>.pdl-cell[data-name=view]{grid-row:auto}.pdl-layout.legend-bottom>div[data-type=layout]>.pdl-cell[data-name=legend]{padding:1em 0 0 0}.pdl-cell[data-name=scale]{padding:.5em}.pdl-cell[data-name=scale]>div{width:4.5em;height:10em}.pdl-layout.legend-bottom .pdl-cell[data-name=scale]>div{width:auto;height:2em}</style><script type="@plotdb/block">var svgns,tau,mk,ringArea,ringCentroid,metrics,clone,eachPoint,cartogram,relax,pieArcs,wedge,toRgb,rgbStr,ramp,rank,unrank,palettes,townWords,mod;module.exports={pkg:{name:"twmapadv",version:"0.0.3",extend:{name:"@makechart/base",path:"lite/index.html"},dependencies:[{name:"topojson-client",version:"3.1.0",path:"dist/topojson-client.min.js",async:false},{name:"d3-array",version:"3.2.4",path:"dist/d3-array.min.js",async:false},{name:"d3-geo",version:"3.1.1",path:"dist/d3-geo.min.js",async:false}],i18n:{"zh-TW":{county:"縣市",town:"鄉鎮",village:"村里",value:"數值",size:"大小",category:"分類",proportion:"比例",aggregated:"村里匯總","aggregated-town":"鄉鎮匯總"}}},init:function(t){var e,n,i,r,o,l;e=t.root,n=t.context,i=t.t,r=t.pubsub,o=t.data,l=t.manager;return mod({context:n,t:i,data:o,manager:l,cls:this._instance.block}).then(function(t){return r.fire("init",{mod:t}).then(function(t){return t[0]})})}};svgns="http://www.w3.org/2000/svg";tau=Math.PI*2;mk=function(t,e,n){var i;i=document.createElementNS(svgns,e);if(n){i.setAttribute("class",n)}t.appendChild(i);return i};ringArea=function(t){var e,n,i,r;e=0;for(n=0,i=t.length-1;n<i;++n){r=n;e+=t[r][0]*t[r+1][1]-t[r+1][0]*t[r][1]}return e/2};ringCentroid=function(t){var e,n,i,r,o,l,a,u,s,c,f,h;e=[0,0,0],n=e[0],i=e[1],r=e[2];for(o=0,l=t.length-1;o<l;++o){a=o;e=t[a],u=e[0],s=e[1];e=t[a+1],c=e[0],f=e[1];h=u*f-c*s;n+=h;i+=(u+c)*h;r+=(s+f)*h}if(!n){return(t[0]||[0,0]).slice()}return[i/(3*n),r/(3*n)]};metrics=function(t){var e,n,i,r,o,l,a,u,s,c,f,h,d,g,p,m;e=[0,0,0,null,0],n=e[0],i=e[1],r=e[2],o=e[3],l=e[4];for(a=0,u=t.length;a<u;++a){s=t[a];for(c=0,f=s.length;c<f;++c){h=c;d=s[c];if(d.length<4){continue}g=Math.abs(ringArea(d));p=ringCentroid(d);m=h===0?g:-g;n+=m;i+=p[0]*m;r+=p[1]*m;if(h===0&&g>l){e=[p,g],o=e[0],l=e[1]}}}o=o||[0,0];return{area:n>0?n:0,c:n>0?[i/n,r/n]:o,label:o}};clone=function(t){return t.map(function(t){return t.map(function(t){return t.map(function(t){return[t[0],t[1]]})})})};eachPoint=function(t,e){var n,i,r,o,l,a,u,s,c,f,h,d=[];for(n=0,i=t.length;n<i;++n){r=t[n];o=[];for(l=0,a=r.length;l<a;++l){u=r[l];s=[];for(c=0,f=u.length;c<f;++c){h=u[c];s.push(e(h))}o.push(s)}d.push(o)}return d};cartogram=function(t,e,n){var i,r,o,l,a,u,s,c,f,h,d,g,p,m,b,v,y,w,x,k,M,_,A,j;n==null&&(n=15);i=t.filter(function(t){return t.v!=null&&isFinite(t.v)&&metrics(t.polys).area>0});if(i.length<2){return}r=[];for(o=0,l=e.length;o<l;++o){a=e[o];eachPoint(a,P)}for(o=0;o<n;++o){u=o;s=i.map(z);c=s.reduce(S,0);f=s.reduce(I,0);if(!(f>0)){return}h=0;d=s.map(O);g=1/(1+h/d.length);for(p=0,l=r.length;p<l;++p){m=r[p];b=[0,0],v=b[0],y=b[1];for(w=0,x=d.length;w<x;++w){k=d[w];M=m[0]-k.x;_=m[1]-k.y;A=Math.sqrt(M*M+_*_);if(A<1e-9){continue}j=A>k.r?k.f*k.r/A:k.f*(A*A/(k.r*k.r))*(4-3*A/k.r);v+=j*M/A;y+=j*_/A}m[0]+=g*v;m[1]+=g*y}}function P(t){return r.push(t)}function z(t){var e;return{m:metrics(t.polys),v:(e=t.v)>0?e:0}}function S(t,e){return t+e.m.area}function I(t,e){return t+e.v}function O(t){var e,n,i,r,o,l,a;e=t.m,n=t.v;i=(r=c*n/f)>(o=c*1e-4)?r:o;l=(r=e.area)>1e-9?r:1e-9;h+=(l>i?l:i)/(l<i?l:i);a=Math.sqrt(l/Math.PI);return{x:e.c[0],y:e.c[1],r:a,f:Math.sqrt(i/Math.PI)-a}}};relax=function(t,e,n){var i,r,o,l,a,u,s,c,f,h,d,g,p,m,b,v,y,w,x,k,M;e==null&&(e=0);n==null&&(n=160);for(i=0,r=n+120;i<r;++i){o=i;l=o<n?.12*(1-o/n):0;if(l){for(a=0,u=t.length;a<u;++a){s=t[a];s.x+=(s.tx-s.x)*l;s.y+=(s.ty-s.y)*l}}for(a=0,c=t.length;a<c;++a){f=a;h=t[f];for(d=f+1,g=t.length;d<g;++d){p=d;m=t[p];b=m.x-h.x;v=m.y-h.y;y=h.r+m.r+e;if(Math.abs(b)>=y||Math.abs(v)>=y){continue}w=Math.sqrt(b*b+v*v);if(w>=y){continue}if(w<1e-6){x=[.001*(p-f),0,.001*(p-f)],b=x[0],v=x[1],w=x[2]}k=(y-w)/w;M=m.r*m.r/(h.r*h.r+m.r*m.r);h.x-=b*k*M;h.y-=v*k*M;m.x+=b*k*(1-M);m.y+=v*k*(1-M)}}}return t};pieArcs=function(i,t){var r,o,l,e,n,a,u,s,c,f,h,d,g,p,m,b,v;i=i.map(function(t){if(isFinite(t)&&t>0){return t}else{return 0}});r=i.reduce(function(t,e){return t+e},0);if(!(r>0)){return[]}o=i.length;if(t==="desc"||o<2){l=0;return function(){var t,e,n=[];for(t=0,e=o;t<e;++t){n.push(t)}return n}().sort(function(t,e){return i[e]-i[t]||t-e}).map(function(t){var e,n;e=tau*i[t]/r;n={i:t,a0:l,a1:l+e};l+=e;return n})}n=[];for(a=2;a<o;++a){u=a;n.push(u)}e=n;s=e.slice(0,Math.ceil(e.length/2));c=e.slice(s.length);f=s.concat([1],c,[0]);h=function(t){if(t===0){return tau*3/4}else if(t===1){return tau/4}else if(in$(t,s)){return 0}else{return tau/2}};d=0;g=[0,0],p=g[0],m=g[1];b=f.map(function(t){var e,n;e=tau*i[t]/r;n=h(t)-(d+e/2);p+=Math.cos(n);m+=Math.sin(n);d+=e;return e});v=Math.atan2(m,p);l=v;return f.map(function(t,e){var n;n={i:t,a0:l,a1:l+b[e]};l+=b[e];return n})};wedge=function(e,n,i,t,r){var o,l,a,u,s,c;if(r-t>=tau-1e-6){return"M"+e+","+(n-i)+"A"+i+","+i+" 0 1 1 "+e+","+(n+i)+"A"+i+","+i+" 0 1 1 "+e+","+(n-i)+"Z"}o=function(t){return[e+i*Math.sin(t),n-i*Math.cos(t)]};l=o(t),a=l[0],u=l[1];l=o(r),s=l[0],c=l[1];return"M"+e+","+n+"L"+a+","+u+"A"+i+","+i+" 0 "+(r-t>Math.PI?1:0)+" 1 "+s+","+c+" Z"};toRgb=function(t,e){var n,i,r,o;t=t.value||t;if(typeof t==="string"&&(n=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(t.trim()))){i=n[1];if(i.length===3){i=i.split("").map(function(t){return t+t}).join("")}return[0,1,2].map(function(t){return parseInt(i.substr(t*2,2),16)})}try{r=e.rgb(t);return[r.r,r.g,r.b].map(function(t){return Math.round(t)})}catch(t){o=t;return[128,128,128]}};rgbStr=function(t,i){i==null&&(i=1);return"rgb("+t.map(function(t){var e,n;return(e=(n=Math.round(t*i))>0?n:0)<255?e:255}).join(",")+")"};ramp=function(l){return function(t){var e,n,i,r,o;if(!(l&&l.length)){return[200,200,200]}if(l.length===1){return l[0]}t=(e=(n=isNaN(t)?0:t)>0?n:0)<1?e:1;i=t*(l.length-1);r=(e=Math.floor(i))<(n=l.length-2)?e:n;o=i-r;return[0,1,2].map(function(t){return l[r][t]+(l[r+1][t]-l[r][t])*o})}};rank=function(s){return function(t){var e,n,i,r,o,l,a,u;e=s.length;if(e<2){return.5}if(t<=s[0]){return 0}if(t>=s[e-1]){return 1}n=[0,e-1],i=n[0],r=n[1];while(r-i>1){o=i+r>>1;if(s[o]<=t){i=o}else{r=o}}l=i;while(l>0&&s[l-1]===s[i]){l--}a=i;while(a<e-1&&s[a+1]===s[i]){a++}u=s[i]===t?(l+a)/2:i+(t-s[i])/(s[i+1]-s[i]||1);return u/(e-1)}};unrank=function(a){return function(t){var e,n,i,r,o,l;e=a.length;if(!e){return 0}n=((i=t>0?t:0)<1?i:1)*(e-1);r=(i=(o=Math.floor(n))<(l=e-2)?o:l)>0?i:0;if(e===1){return a[0]}return a[r]+(a[r+1]-a[r])*(n-r)}};palettes={sequential:{name:"orange",colors:["#fff5eb","#fdd0a2","#fd8d3c","#d94801","#7f2704"]},diverging:{name:"rdbu",colors:["#2166ac","#67a9cf","#f7f7f7","#ef8a62","#b2182b"]}};townWords=["全區","全部","總計","合計","小計","全鄉","全鎮","全市","全區合計","total","all"];mod=function(t){var e,n,o,G,T,V,qt,J,i,K,ft;e=t.context,n=t.t,o=t.data,G=t.manager,T=t.cls;V=e.chart,qt=e.ldcolor,J=e.topojson;i=V.utils,K=i.format,ft=i.anim.join;n=n||function(t){return t};return Promise.resolve().then(function(){var t,F,e,Z,H,n,X,i,r;t=o.level||"county/臺北市";F=t==="town";e=F?[]:t.split("/");Z=e[1]||"";H=e[2];n="county/"+Z;X=F?{file:"town.map.js",type:"town",upper:"county",len:5,un:"c",ln:"t",sample:"全國"}:{file:n+".village.map.js",type:n+"/village",upper:"town",len:8,un:"t",ln:"v",sample:Z};i="2.7.0";r=[{name:"pdmaptw",version:i,path:"index.min.js",async:false},{name:"pdmaptw",version:i,path:X.file,async:false}];return G.rescope.load(r,T.context()).then(function(t){var B;B=t.pdmaptw;return B.get(X.type).then(function(t){var R,e,$,a,n,r,i,o,l,u,s,c,f,h,d,g,p,m,b,v,y,w,x,k,M,_,A,q,E,j,P,L,z,C,S,W,I,O;R=function(t){return B.normalize((t!=null?t:"")+"").trim()};e=R(Z);$=function(t){return R(t).replace(e,"")};a=B.projection();n=function(t,o,e){var n,l;if(!(t&&t.topo.objects[e])){return[]}n=t.topo,l=t.meta;return J.feature(n,n.objects[e]).features.map(function(t){var e,n,i,r;e=t.properties;n=t.geometry||{};i=n.type==="Polygon"?[n.coordinates]:n.type==="MultiPolygon"?n.coordinates:[];i=i.map(function(t){return t.map(function(t){return t.map(function(t){return a(t)})})});r=function(t){if(e[t]!=null){return R(l.name[e[t]])}else{return""}};return{code:e.code,level:o,town:r(X.un),village:r(X.ln),polys:i,tcode:(e.code+"").substring(0,X.len)}})};r=n(t,"town",X.upper);i=n(t,"village","pdmaptw");if(H){r=r.filter(function(t){return t.code===H||t.town===R(H).replace(R(Z),"")});o=Object.fromEntries(r.map(function(t){return[t.code,true]}));i=i.filter(function(t){return o[t.tcode]})}l=r.length?(u=Object.fromEntries(r.map(function(t){return[t.code,true]})),s=J.merge(t.topo,t.topo.objects[X.upper].geometries.filter(function(t){return u[t.properties.code]})),(s.type==="Polygon"?[s.coordinates]:s.coordinates).map(function(t){return t.map(function(t){return t.map(function(t){return a(t)})})})):[];c=function(t){return Math.abs(ringArea(t[0]))};f=l.reduce(function(t,e){return t+c(e)},0);h=function(t){var i;i=[Infinity,Infinity,-Infinity,-Infinity];eachPoint(t,function(t){var e,n;return i=[(e=i[0])<(n=t[0])?e:n,(e=i[1])<(n=t[1])?e:n,(e=i[2])>(n=t[0])?e:n,(e=i[3])>(n=t[1])?e:n]});return i};d=h(l.filter(function(t){return c(t)>=f*.01}));g=Math.hypot(d[2]-d[0],d[3]-d[1]);p=l.filter(function(t){var e,n,i,r,o,l;e=h([t]);n=(i=(r=d[0]-e[2])>(o=e[0]-d[2])?r:o)>0?i:0;l=(i=(r=d[1]-e[3])>(o=e[1]-d[3])?r:o)>0?i:0;return Math.hypot(n,l)<=g*2});m=[Infinity,Infinity,-Infinity,-Infinity],b=m[0],v=m[1],y=m[2],w=m[3];eachPoint(p,function(t){var e;b=b<(e=t[0])?b:e;v=v<(e=t[1])?v:e;y=y>(e=t[0])?y:e;return w=w>(e=t[1])?w:e});x=p.length<l.length;k=1e3/(y-b||1);for(M=0,_=(m=r.concat(i,[{polys:l}])).length;M<_;++M){A=m[M];eachPoint(A.polys,N)}q=1e3;E=(w-v)*k;for(M=0,_=(m=r.concat(i)).length;M<_;++M){A=m[M];import$(A,metrics(A.polys))}j={};for(M=0,_=i.length;M<_;++M){P=i[M];(j[L=P.tcode]||(j[L]=[])).push(P)}z={};for(M=0,_=(m=r.concat(i)).length;M<_;++M){A=m[M];z[A.code]=A}C={};for(M=0,_=r.length;M<_;++M){S=r[M];C[S.town]=S}W={};for(M=0,_=i.length;M<_;++M){P=i[M];W[P.tcode+"/"+P.village]=P}I={towns:r,villages:i,outline:l,main:p,overflow:x,W:q,H:E,villOf:j,feat:z,national:F};return{sample:function(){var t;t=G.getUrl({ns:T.ns,name:T.name,version:T.version,path:"sample/"+X.sample+".json",type:"json"});return fetch(t).then(function(t){if(t.ok){return t.json()}else{return Promise.reject(new Error(t.status+""))}})["catch"](function(t){console.warn("[twmapadv] sample data for "+X.sample+" not found:",t);return{head:[],units:{},rows:[]}}).then(function(t){var e,n,i;e=t.head,n=t.units,i=t.rows;if(H){i=i.filter(function(t){return in$(R(t[0]),r.map(function(t){return t.town}))})}return{raw:i.map(function(n){return Object.fromEntries(e.map(function(t,e){return[t,n[e]]}))}),binding:{town:{key:e[0]},village:{key:e[1]},value:{key:"人口密度",unit:n.人口密度},size:{key:"人口",unit:n.人口},cat:{key:"高齡分級"},parts:[{key:"男",unit:n.男},{key:"女",unit:n.女}]}}})},config:(m=V.utils.config.from({preset:"default",tip:"tip"}),m.mode={type:"choice",values:["map","cartogram","bubble"],default:"map"},m.colorBy={type:"choice",values:["auto","value","cat"],default:"auto"},m.heat={mode:{type:"choice",values:["sequential","diverging"],default:"sequential"},scale:{type:"choice",values:["linear","log","pow","quantile"],default:"linear"},exponent:{type:"number",default:.5,min:.1,max:5,step:.1},center:{mode:{type:"choice",values:["median","mean","manual"],default:"median"},value:{type:"number",default:0}},symmetric:{type:"boolean",default:true},steps:{type:"number",default:0,min:0,max:12,step:1},sequential:{type:"palette",default:palettes.sequential},diverging:{type:"palette",default:palettes.diverging},empty:{type:"color",default:"#e5e5e5"}},m.legend=(O=import$({},V.utils.config.preset.legend),O.format={type:"format",default:".3s"},O),m.village={mode:{type:"choice",values:["click","all","none"],default:"click"},aggregate:{type:"choice",values:["sum","mean","none"],default:"sum"},domain:{type:"choice",values:["level","shared"],default:"level"},zoom:{type:"boolean",default:false}},m.border={color:{type:"color",default:"#fff"},width:{type:"number",default:1,min:0,max:20,step:.1},linejoin:{type:"choice",values:["round","bevel","miter"],default:"round"},village:{color:{type:"color",default:"#fff"},width:{type:"number",default:.4,min:0,max:20,step:.1}}},m.extrude={enabled:{type:"boolean",default:false},height:{type:"number",default:.25,min:0,max:2,step:.01},tilt:{type:"number",default:55,min:0,max:85,step:1},angle:{type:"number",default:-20,min:-180,max:180,step:1},rotate:{type:"choice",values:["drag","auto","both","none"],default:"drag"},speed:{type:"number",default:12,min:-180,max:180,step:1},base:{enabled:{type:"boolean",default:true},color:{type:"color",default:"#d8d8d8"}},shade:{type:"number",default:.25,min:0,max:1,step:.01}},m.cartogram={iteration:{type:"number",default:15,min:1,max:60,step:1}},m.bubble={scale:{type:"number",default:1,min:.1,max:4,step:.05},overlap:{type:"boolean",default:false},padding:{type:"number",default:1,min:0,max:20,step:.5},leader:{type:"boolean",default:true},leaderColor:{type:"color",default:"#999"},basemap:{type:"boolean",default:true},basemapColor:{type:"color",default:"#eeeeee"},stroke:{type:"color",default:"#fff"},strokeWidth:{type:"number",default:.5,min:0,max:10,step:.1},pie:{type:"choice",values:["side","desc","none"],default:"side"}},m.label={enabled:{type:"boolean",default:true},village:{type:"boolean",default:false},font:V.utils.config.from({preset:"font"}),color:{type:"color",default:"#222"},halo:{type:"color",default:"#fff"},haloWidth:{type:"number",default:2,min:0,max:10,step:.5}},m.filterLevel={type:"choice",values:["town","village"],default:"town"},m),dimension:{town:{type:"N",name:F?"county":"town",priority:1},village:{type:"N",name:F?"town":"village",priority:2},value:{type:"R",name:"value",priority:3},size:{type:"R",name:"size",priority:4},cat:{type:"C",name:"category",priority:5},parts:{type:"R",name:"proportion",priority:6,multiple:true}},init:function(){var e,t,n,i,r,o,l,a,u,s,c,p,f,h=this;this.geo=I;this.expanded={};this.angle=null;this.tint=e=new V.utils.tint;this.g=Object.fromEntries(["view","legend","scale"].map(function(t){return[t,h.layout.getGroup(t)]}));import$(this.g,Object.fromEntries(["bg","base","units","solid","outline","leader","bubble","label"].map(function(t){return[t,mk(h.g.view,"g",t)]})));this.pool=[];this._t3=document.createElementNS(svgns,"g");this.g.bg=mk(this.g.bg,"rect");this.clip=mk(mk(mk(this.g.view,"defs"),"clipPath"),"rect");this.clip.parentNode.setAttribute("id","tmap-clip-"+Math.random().toString(36).substring(2));this.g.bg.setAttribute("fill","transparent");this.node={};for(t=0,i=(n=I.towns.concat(I.villages)).length;t<i;++t){r=n[t];o=mk(this.g.units,"g","unit "+r.level);o.__data__={code:r.code,_raw:null};l=mk(o,"path","top");l.__data__=o.__data__;a=mk(this.g.bubble,"g","bubble "+r.level);a.__data__=o.__data__;u=mk(this.g.label,"text");u.setAttribute("text-anchor","middle");u.setAttribute("dominant-baseline","central");u.setAttribute("paint-order","stroke");u.style.pointerEvents="none";s=mk(this.g.leader,"line");s.setAttribute("stroke-dasharray","2 2");this.node[r.code]={g:o,top:l,bubble:a,label:u,line:s}}this.base={top:mk(this.g.base,"path"),wall:mk(this.g.base,"path")};this.outline={};for(t=0,i=(n=I.towns).length;t<i;++t){c=n[t];this.outline[c.code]=mk(this.g.outline,"path");this.outline[c.code].setAttribute("fill","none")}this.g.outline.style.pointerEvents="none";this.g.leader.style.pointerEvents="none";this.legend=new V.utils.legend({root:this.root,name:"legend",layout:this.layout,shape:function(t){return this.setAttribute("fill",e.get(t.key))}});this.legend.on("select",function(){h.bind();h.resize();return h.render()});this.tip=new V.utils.tip({root:this.root,accessor:function(t){var e,n,i;e=t.evt;if(!(e.target&&(n=e.target.__data__)&&n.code&&(i=h.geo.feat[n.code]))){return null}return h.local.tip(i)},range:function(){return h.layout.getNode("view").getBoundingClientRect()}});this.tip.tip.style.maxWidth="16em";this.tip.tip.querySelector("[ld=value-alt]").style.whiteSpace="pre-line";p=this.tip.render;this.tip.render=function(t){var e,n,i,r,o,l,a,u,s,c,f,h,d,g;t==null&&(t={});p.call(this,t);if(!(this.enabled&&t.evt)){return}e=this.root.getBoundingClientRect();n=this.range?this.range():e;i=this.tip.getBoundingClientRect();r=[t.evt.clientX-e.x,t.evt.clientY-e.y,this.margin],o=r[0],l=r[1],a=r[2];r=[n.x-e.x,n.y-e.y],u=r[0],s=r[1];r=[u+n.width,s+n.height],c=r[0],f=r[1];h=o-a-i.width;d=l-a-i.height;if(h<u){h=o+a}if(d<s){d=l+a}h=(r=h<(g=c-i.width)?h:g)>u?r:u;d=(r=d<(g=f-i.height)?d:g)>s?r:s;return this.tip.style.transform="translate("+h+"px,"+d+"px)"};f=null;this.g.view.addEventListener("pointerdown",function(t){return f=h.drag={x:t.clientX,moved:false,angle:h.local.angle()}});this.root.addEventListener("pointermove",function(t){var e,n;if(!f){return}if(!t.buttons){return f=h.drag=null}e=t.clientX-f.x;if(Math.abs(e)>3){f.moved=true}if(!(f.moved&&h.local.is3d()&&((n=h.cfg.extrude.rotate)==="drag"||n==="both"))){return}h.angle=f.angle-e*.5;return h.local.draw(true)});this.root.addEventListener("pointerup",function(){h.drag=null;return setTimeout(function(){return f=null},0)});return this.g.view.addEventListener("click",function(t){var e;if(f&&f.moved){return}e=(t.target||{}).__data__;if(e&&e.code){return h.local.click(t,h.geo.feat[e.code])}else{return h.local.reset()}})},destroy:function(){this.tip.destroy();return this.legend.destroy()},filter:function(t,e){},parse:function(){var n,t,e,i,r,o,l,a,u,s,c,f,h,d,g,p,m,b,v,y,w,x,k,M=[],_=this;n=function(t){if(t!=null&&t!==""&&!isNaN(+t)){return+t}else{return undefined}};this.rec={};t=function(t){var e;e=Array.isArray(t.parts)?t.parts:t.parts!=null?[t.parts]:[];return{value:n(t.value),size:n(t.size),cat:t.cat,parts:e.map(n),row:t}};for(e=0,r=(i=this.data).length;e<r;++e){o=i[e];l=((o.town!=null?o.town:"")+"").trim();a=((o.village!=null?o.village:"")+"").trim();u=this.geo.feat[l]||C[$(l)];if(u&&u.level==="village"){this.rec[u.code]=(s=t(o),s.keys=[o.town],s);continue}if(!u&&this.geo.feat[a]){u=this.geo.feat[this.geo.feat[a].tcode]}if(!u||u.level!=="town"){continue}if(!a||in$(a.toLowerCase(),townWords)){this.rec[u.code]=(s=t(o),s.keys=[o.town],s)}else{c=this.geo.feat[a]||W[u.code+"/"+R(a)]||W[u.code+"/"+R(a).replace(u.town,"")];if(c&&c.level==="village"){this.rec[c.code]=(s=t(o),s.keys=[o.town],s.vname=o.village,s)}}}f=this.cfg.village.aggregate;for(e=0,r=(i=this.geo.towns).length;e<r;++e){l=i[e];if(this.rec[l.code]||f==="none"){continue}h=(this.geo.villOf[l.code]||[]).map(A).filter(j);if(!h.length){continue}d=P;g={};for(p=0,m=h.length;p<m;++p){b=h[p];if(b.cat!=null){g[b.cat]=(g[b.cat]||0)+1}}v=z().sort(S)[0];w=Math.max.apply(null,h.map(I));x=O().map(q);k=Array.from(new Set([].concat.apply([],h.map(E))));M.push(this.rec[l.code]={value:d("value"),size:d("size"),cat:v,parts:x,keys:k,agg:true})}return M;function A(t){return _.rec[t.code]}function j(t){return t}function P(e){var t,n;t=h.map(function(t){return t[e]}).filter(function(t){return t!=null});if(!t.length){return undefined}n=t.reduce(function(t,e){return t+e},0);if(f==="mean"){return n/t.length}else{return n}}function z(){var t=[];for(y in g){t.push(y)}return t}function S(t,e){return g[e]-g[t]}function I(t){return t.parts.length}function O(){var t,e,n=[];for(t=0,e=w;t<e;++t){n.push(t)}return n}function q(e){var t,n;t=h.map(function(t){return t.parts[e]}).filter(function(t){return t!=null});if(!t.length){return undefined}n=t.reduce(function(t,e){return t+e},0);if(f==="mean"){return n/t.length}else{return n}}function E(t){return t.keys}},resize:function(){var t;this.root.querySelector(".pdl-layout").classList.toggle("legend-bottom",this.cfg.legend.position==="bottom");this.tip.toggle(((t=this.cfg).tip||(t.tip={})).enabled!=null?this.cfg.tip.enabled:true);this.legend.config(this.cfg.legend);this.local.prepare();this.legend.update(false);this.layout.update(false);return this.box=this.layout.getBox("view")},render:function(){if(!this.box){return}this.local.draw();this.local.drawScale();this.legend.render();if(this.local.autoRotate()){return this.start()}else{return this.stop()}},tick:function(t,e){e==null&&(e=0);if(!(this.local.autoRotate()&&e)||this.drag&&this.drag.moved){return}this.angle=this.local.angle()+this.cfg.extrude.speed*e/1e3;return this.local.draw(true)},local:{is3d:function(){return this.cfg.extrude.enabled&&this.cfg.mode!=="bubble"},angle:function(){if(this.angle!=null){return this.angle}else{return this.cfg.extrude.angle}},autoRotate:function(){var t;return this.local.is3d()&&((t=this.cfg.extrude.rotate)==="auto"||t==="both")},isPie:function(){return this.cfg.mode==="bubble"&&this.cfg.bubble.pie!=="none"&&Array.isArray(this.binding.parts)&&this.binding.parts.length>=2},colorBy:function(){if(this.cfg.colorBy==="cat"){return this.binding.cat?"cat":"value"}if(this.cfg.colorBy==="value"){return"value"}if(this.binding.value){return"value"}else if(this.binding.cat){return"cat"}else{return"value"}},expanded:function(t){var e;if(!(this.geo.villOf[t.code]||[]).length){return false}e=this.cfg.village.mode;return e==="all"||e==="click"&&this.expanded[t.code]},units:function(){var t,e,n,i,r;t=[];for(e=0,i=(n=this.geo.towns).length;e<i;++e){r=n[e];if(this.local.expanded(r)){t=t.concat(this.geo.villOf[r.code])}else{t.push(r)}}return t.filter(function(t){return t.area>0})},prepare:function(){var e,t,n,i,r,o,l,a,u,s,c,f,h,d,g,p,m,b=this;e=function(t){if(b.cfg.village.domain==="shared"){return"all"}else{return t.level}};t={};for(n in i=this.rec){r=i[n];o=this.geo.feat[n];l=t[a=e(o)]||(t[a]=[]);l.push(r)}this.dom={};for(u in t){s=t[u];c=s.map(v).filter(y).sort(w);f=s.map(x).filter(k);this.dom[u]={value:c,scale:this.local.heat(c),smax:f.length?Math.max.apply(null,f.map(M)):0};h=f.reduce(_,0);d=this.geo.W*this.geo.H*.3;this.dom[u].rmax=h?Math.sqrt(d/(Math.PI*h)):0}this.domOf=function(t){return b.dom[e(t)]||{value:[],scale:null,smax:0,rmax:0}};g=this.local.colorBy();this.tint.reset();this.tint.mode(V.utils.tint.mode.ordinal);this.tint.set(this.cfg.palette);if(this.local.isPie()){this.parts=this.binding.parts.map(function(t,e){return{key:t.name||t.key||e+1+"",text:t.name||t.key||e+1+""}});this.legend.data(this.parts.map(function(t,e){return t.value=-e,t}))}else if(g==="cat"){p=[];for(n in i=this.rec){r=i[n];if(r.cat!=null&&!in$(r.cat,p)){p.push(r.cat)}}p.sort();this.legend.data(p.map(function(t){return{key:t,text:t+""}}))}else{this.legend.data([])}this.showScale=!this.local.isPie()&&g==="value"&&this.binding.value!=null&&this.cfg.legend.enabled!==false;m=this.layout.getNode("scale");return m.style.display=this.showScale?"":"none";function v(t){return t.value}function y(t){return t!=null&&isFinite(t)}function w(t,e){return t-e}function x(t){if(t.size!=null){return t.size}else{return t.value}}function k(t){return t!=null&&isFinite(t)}function M(t){return Math.abs(t)}function _(t,e){return t+Math.abs(e)/(b.dom[u].smax||1)}},heat:function(t){var e,n,r,i,o,l,a,u,s,c,f,h,d,g,p,m,b,v,y;if(!t.length){return null}e=this.cfg.heat;n=e.exponent||.5;r=function(){switch(e.scale){case"log":return function(t){return(t<0?-1:1)*Math.log10(1+Math.abs(t))};case"pow":return function(t){if(t<0){return-Math.pow(-t,n)}else{return Math.pow(t,n)}};case"quantile":return rank(t);default:return function(t){return t}}}();i=[t[0],t[t.length-1]],o=i[0],l=i[1];a=e.mode==="diverging";u=!a?null:e.center.mode==="manual"?e.center.value:e.center.mode==="mean"?t.reduce(function(t,e){return t+e},0)/t.length:(s=t.length/2,t.length%2?t[Math.floor(s)]:(t[s-1]+t[s])/2);if(a&&e.symmetric){c=Math.max(Math.abs(r(l)-r(u)),Math.abs(r(u)-r(o)));i=[r(u)-c,r(u)+c],f=i[0],h=i[1]}else{i=[r(o),r(l)],f=i[0],h=i[1]}d=a?r(u):null;g=Math.round(e.steps||0);p=function(t){var e,n,i;e=r(t);n=!a?(e-f)/(h-f||1):e<d?.5*(e-f)/(d-f||1):.5+.5*(e-d)/(h-d||1);n=(i=n>0?n:0)<1?i:1;if(g>1){n=Math.min(g-1,Math.floor(n*g))/(g-1)}return n};m=a?e.diverging:e.sequential;b=(m&&m.colors&&m.colors.length&&m.colors||palettes[a?"diverging":"sequential"].colors).map(function(t){return toRgb(t,qt)});v=ramp(b);y=function(){switch(e.scale){case"log":return function(t){return(t<0?-1:1)*(Math.pow(10,Math.abs(t))-1)};case"pow":return function(t){return(t<0?-1:1)*Math.pow(Math.abs(t),1/n)};case"quantile":return unrank(t);default:return function(t){return t}}}();return{t:p,lo:o,hi:l,center:u,color:v,div:a,inv:y,tlo:f,thi:h,tc:d}},color:function(t){var e,n;e=this.rec[t.code];if(!e){return null}if(this.local.colorBy()==="cat"){return e.cat!=null&&this.legend.isVisible(e.cat)?toRgb(qt.web(this.tint.get(e.cat)),qt):null}n=this.domOf(t).scale;if(!(n&&e.value!=null&&isFinite(e.value))){return null}return n.color(n.t(e.value))},height:function(t){var e,n,i,r,o,l,a;e=this.rec[t.code];if(!e){return 0}n=e.value!=null?e.value:e.size;i=this.domOf(t).value;if(!(n!=null&&i.length)){return 0}r=(o=i[0])<0?o:0;l=i[i.length-1];if(l<=r){return 1}return(o=(a=(n-r)/(l-r))>0?a:0)<1?o:1},ratio:function(t,e,n){var i;i=this.rec[t.code];if(!(i&&i.row&&i.row.subset)){return null}e=e||(this.binding.size?"size":"value");return this.subset.ratio(i.row,e,n)},picked:function(t){var e,n,i,r,o,l,a,u;e=(n=((this.cfg.common||{}).subset||{}).opacity)!=null?n:.2;i=this.rec[t.code]||{};r=this.subset.mode();if((r==="dim"||r==="partial"&&this.cfg.mode!=="bubble")&&this.local.ratio(t)===0){return e}o=t.level==="village"?this.rec[t.tcode]||{}:i;l=((this.binding.town||{}).filter||{}).value;a=((this.binding.village||{}).filter||{}).value;u=i.keys||o.keys||[];if(l&&!u.some(function(t){return in$(t,l)})){return e}if(a&&t.level==="village"&&!(i.vname!=null&&in$(i.vname,a))){return e}if(this.local.colorBy()==="cat"&&!this.local.isPie()&&i.cat!=null&&!this.legend.isSelected(i.cat)){return this.legend.opacity()}return 1},shape:function(){var t,e,n,i,r,o,l,a,u,s,c,f,h,d,g,p,m=this;t=this.cfg.mode;e=this.cfg.village.mode==="all";n=function(t){var e,n;e=m.rec[t.code];if(!e){return undefined}n=e.size!=null?e.size:e.value;if(n!=null){return Math.abs(n)}else{return undefined}};i=[t,e,this.cfg.cartogram.iteration].join("/")+(t==="cartogram"?"/"+this.geo.towns.concat(this.geo.villages).map(n).join(","):"");if(this._shape&&this._shape.key===i){return this._shape}r={};for(o=0,a=(l=this.geo.towns.concat(this.geo.villages)).length;o<a;++o){u=l[o];r[u.code]=u.polys}s=this.geo.outline;if(t==="cartogram"){r={};for(o=0,a=(l=this.geo.towns.concat(this.geo.villages)).length;o<a;++o){u=l[o];r[u.code]=clone(u.polys)}s=clone(this.geo.outline);c=e&&this.geo.villages.some(function(t){return m.rec[t.code]})?this.geo.villages:this.geo.towns;f=c.map(function(t){return{polys:r[t.code],v:n(t)}});h=[s].concat(this.geo.towns.concat(this.geo.villages).map(function(t){return r[t.code]}));cartogram(f,h,this.cfg.cartogram.iteration)}d={};for(g in r){p=r[g];d[g]=t==="cartogram"?metrics(p):this.geo.feat[g]}return this._shape={key:i,polys:r,outline:s,ms:d}},focus:function(){var t,e=this;if(!(this.cfg.village.zoom&&this.cfg.village.mode==="click")){return null}t=this.geo.towns.filter(function(t){return e.local.expanded(t)});if(t.length){return t}else{return null}},viewParam:function(){var t,e,n,i,r,o,l,a,u,s,c,f,h,d,g,p,m,b,v,y,w,x;t=this.box;e=10;n=this.local.is3d();i=this.geo.W/2;r=this.geo.H/2;o=[this.geo.W,this.geo.H],l=o[0],a=o[1];u=this.local.focus();s=this.geo.main;if(u){c=this.local.shape();s=[].concat.apply([],u.map(function(t){return c.polys[t.code]}));o=[Infinity,Infinity,-Infinity,-Infinity],f=o[0],h=o[1],d=o[2],g=o[3];eachPoint(s,function(t){var e;f=f<(e=t[0])?f:e;h=h<(e=t[1])?h:e;d=d>(e=t[0])?d:e;return g=g>(e=t[1])?g:e});o=[(f+d)/2,(h+g)/2,d-f||1,g-h||1],i=o[0],r=o[1],l=o[2],a=o[3]}this.clip.setAttribute("width",t.width);this.clip.setAttribute("height",t.height);if(u||this.geo.overflow){this.g.view.setAttribute("clip-path","url(#"+this.clip.parentNode.id+")")}else{this.g.view.removeAttribute("clip-path")}if(!n){p=(o=Math.min((t.width-2*e)/l,(t.height-2*e)/a))>.01?o:.01;return{is3d:n,cx:i,cy:r,s:p,ox:t.width/2-i*p,oy:t.height/2-r*p}}m=this.cfg.extrude.tilt*Math.PI/180;o=[Math.cos(m),Math.sin(m)],b=o[0],v=o[1];y=0;eachPoint(s,function(t){var e;return y=y>(e=Math.hypot(t[0]-i,t[1]-r))?y:e});w=this.cfg.extrude.height*this.geo.W;x=this.geo.W*.015;p=(o=Math.min((t.width-2*e)/(2*y),(t.height-2*e)/(2*y*b+(w+x)*v)))>.01?o:.01;return{is3d:n,cx:i,cy:r,s:p,hmax:w,thick:x,ox:t.width/2,oy:t.height/2+(w-x)*v*p/2}},mkview:function(t){var n,i,r,o,l,e,a,u,s,c,f,h,d,g,p;n=t.cx,i=t.cy,r=t.s,o=t.ox,l=t.oy;if(!t.is3d){return e=import$({},t),e.pt=function(t,e){return[o+t*r,l+e*r]},e}a=this.local.angle()*Math.PI/180;u=this.cfg.extrude.tilt*Math.PI/180;e=[Math.cos(a),Math.sin(a),Math.cos(u),Math.sin(u)],s=e[0],c=e[1],f=e[2],h=e[3];d=function(t,e){return[(t-n)*s-(e-i)*c,(t-n)*c+(e-i)*s]};g=function(t,e,n){n==null&&(n=0);return[o+t*r,l+e*f*r-n*h*r]};p=function(t,e,n){var i;n==null&&(n=0);i=d(t,e);return g(i[0],i[1],n)};return e=import$({},t),e.rot=d,e.prj=g,e.pt=p,e},view:function(){return this.local.mkview(this.local.viewParam())},draw:function(t){var i,r,o,e,C,l,n,a,u,W,s,c,f,h,d,g,p,m,b,v,y,w,L,x,N,B,F,k,M,_,A,j,P,z,S,I,O,Z,H,X,G,q,T,V,E,J,K,U,R,Y,$=this;t==null&&(t=false);i=this.cfg;r=this.local.view();o=this.local.shape();e=this.local.units();C=Object.fromEntries(e.map(function(t){return[t.code,true]}));l=i.mode==="bubble";this.g.bg.setAttribute("width",this.box.width);this.g.bg.setAttribute("height",this.box.height);for(n=0,a=e.length;n<a;++n){u=e[n];this.node[u.code].g.__data__._raw=((this.rec[u.code]||{}).row||{})._raw||null}if(r.is3d){return this.local.draw3d(t)}this.s3=null;this.g.solid.style.display="none";this.g.base.style.display="none";W=this.local.isPie();s=t?0:350;c=function(t,e,n){n==null&&(n=s);return $.anim.tween(t,e,{duration:n})};f=this.prev;h=f?f.v:r;d=function(t){return!f||f.is3d||!f.shown[t]};g=function(t){if(f&&f.is3d){return f.h(t)}else{return 0}};p={};m=function(t,e,n){e==null&&(e=0);n==null&&(n=r);return t.map(function(t){return t.map(function(t){if(t.length<2){return""}return"M"+t.slice(0,-1).map(function(t){return n.pt(t[0],t[1],e).map(function(t){return t.toFixed(2)}).join(",")}).join("L")+"Z"}).join("")}).join("")};b=toRgb(i.heat.empty,qt);for(n=0,a=(v=this.geo.towns.concat(this.geo.villages)).length;n<a;++n){u=v[n];y=this.node[u.code];if(!C[u.code]){y.g.style.display="none";y.bubble.style.display="none";y.line.style.display="none";continue}y.g.style.display="";w=o.polys[u.code];L=this.local.color(u);x=this.local.picked(u);N=u.level==="town"?i.border.width:i.border.village.width;B=u.level==="town"?i.border.color:i.border.village.color;F=l?i.bubble.basemap?toRgb(i.bubble.basemapColor,qt):null:L||b;if(l&&!i.bubble.basemap){y.g.style.display="none"}p[u.code]=true;if(d(u.code)){this.anim.interrupt(y.top);y.top.setAttribute("d",m(w,g(u.code),h))}c(y.top,{d:m(w),fill:F?rgbStr(F):"none",stroke:B,"stroke-width":N,"stroke-linejoin":i.border.linejoin,opacity:x})}for(n=0,a=(v=this.geo.towns).length;n<a;++n){k=v[n];M=this.outline[k.code];if(l||!this.local.expanded(k)){M.style.display="none";continue}M.style.display="";p["o:"+k.code]=true;if(d("o:"+k.code)){this.anim.interrupt(M);M.setAttribute("d",m(o.polys[k.code],g(k.code),h))}c(M,{d:m(o.polys[k.code]),stroke:i.border.color,"stroke-width":i.border.width*1.5,"stroke-linejoin":i.border.linejoin})}_=l?this.local.bubbles(e,o):null;for(n=0,a=e.length;n<a;++n){u=e[n];y=this.node[u.code];if(!l){y.bubble.style.display="none";y.line.style.display="none";continue}A=_[u.code];y.bubble.style.display="";v=r.pt(A.x,A.y),j=v[0],P=v[1];z=A.r*r.s;v=r.pt(A.tx,A.ty),S=v[0],I=v[1];x=this.local.picked(u);O=Math.hypot(S-j,I-P);if(i.bubble.leader&&!i.bubble.overlap&&O>z+1){y.line.style.display="";v=[(S-j)/O,(I-P)/O],Z=v[0],H=v[1];c(y.line,{x1:j+Z*z,y1:P+H*z,x2:S,y2:I,stroke:i.bubble.leaderColor,"stroke-width":.8,opacity:x})}else{y.line.style.display="none"}X=this.rec[u.code]||{};G=(X.row||{})._raw||null;q=W?pieArcs((X.parts||[]).map(D),i.bubble.pie):[];if(!q.length){q=[{i:-1,a0:0,a1:tau}]}T=this.subset.mode()==="partial";V=Q;E=tt;J=et;K=ft({root:y.bubble,tag:"path",cls:"wedge",data:q,key:nt});K.exit.map(it);K.nodes.map(rt);U=!T?[]:q.filter(ot).map(lt);R=ft({root:y.bubble,tag:"path",cls:"subset",data:U,key:at});R.exit.map(ut);R.nodes.map(st);R.nodes.map(ct)}Y=function(t,e,n){var i,r;n==null&&(n=0);if(l){i=_[e.code];return t.pt(i.x,i.y)}r=o.ms[e.code];return t.pt(r.label[0],r.label[1],n)};this.local.labels({units:e,dur:s,drawn:p,fresh:d,pos:function(t){if(l&&_[t.code].r*r.s<10){return null}else{return Y(r,t)}},start:function(t){return Y(h,t,g(t.code))}});return this.prev={is3d:false,v:r,shown:p};function D(t,e){if($.legend.isVisible($.parts[e].key)){return t}else{return 0}}function Q(t){if(t.i>=0){return toRgb(qt.web($.tint.get($.parts[t.i].key)),qt)}else{return $.local.color(u)||b}}function tt(t){if(t.i>=0){return $.local.ratio(u,"parts",t.i)}else{return $.local.ratio(u)}}function et(t){return x*(t.i>=0&&!$.legend.isSelected($.parts[t.i].key)?$.legend.opacity():1)}function nt(t){return t.i}function it(t){$.anim.interrupt(t);return t.remove()}function rt(t){var e,n;e=t.__data__;t.__data__=(e.code=u.code,e._raw=G,e);n=V(e);return c(t,{d:wedge(j,P,z,e.a0,e.a1),fill:rgbStr(T&&E(e)!=null?toRgb($.subset.color(rgbStr(n)),qt):n),stroke:i.bubble.stroke,"stroke-width":i.bubble.strokeWidth,opacity:J(e)})}function ot(t){return E(t)!=null}function lt(t){return t.k=Math.sqrt(E(t)),t}function at(t){return t.i}function ut(t){$.anim.interrupt(t);return t.remove()}function st(t){var e;e=t.__data__;t.setAttribute("pointer-events","none");return c(t,{d:wedge(j,P,z*e.k,e.a0,e.a1),fill:rgbStr(V(e)),opacity:J(e)})}function ct(t){return y.bubble.appendChild(t)}},labels:function(t){var e,n,i,r,o,l,a,u,s,c,f,h,d,g,p,m,b,v,y,w,x=this,k=[];e=t.units,n=t.pos,i=t.start,r=t.dur,o=t.drawn,l=t.fresh,a=t.depth;u=this.cfg;s=u.label.font||{};c=u.mode==="bubble"||u.label.village?[]:this.geo.towns.filter(function(t){return x.local.expanded(t)});f=Object.fromEntries(e.concat(c).map(function(t){return[t.code,true]}));for(h=0,g=(d=this.geo.towns.concat(this.geo.villages)).length;h<g;++h){p=d[h];if(!f[p.code]){this.node[p.code].label.style.display="none"}}m=[];for(h=0,g=(d=e.concat(c)).length;h<g;++h){p=d[h];b=this.node[p.code];v=u.label.enabled&&(p.level==="town"||u.label.village)?n(p):null;if(!v){b.label.style.display="none";continue}m.push(p);b.label.style.display="";o["l:"+p.code]=true;if(l("l:"+p.code)){y=i(p);b.label.setAttribute("x",y[0]);b.label.setAttribute("y",y[1])}b.label.textContent=p.level==="town"?p.town:p.village;b.label.setAttribute("class",s.family?s.family.className||"":"");w=s.size||"1em";this.anim.tween(b.label,{x:v[0],y:v[1],fill:u.label.color,stroke:u.label.halo,"stroke-width":u.label.haloWidth,"font-size":p.level==="village"?"calc("+w+" * 0.7)":w,opacity:this.local.picked(p)},{duration:r})}if(a){m.sort(function(t,e){return a(t)-a(e)})}else{m=m.filter(function(t){return in$(t,c)})}for(h=0,g=m.length;h<g;++h){p=m[h];k.push(this.g.label.appendChild(this.node[p.code].label))}return k},adjacency:function(t){var e,n,i,r,o,l,a,u,s,c,f,h,d,g,p,m,b,v,y,w,x;n=[];for(i in t){n.push(i)}e=n;r=e.join(",")+"/"+this.local.shape().key;if(this._adj&&this._adj.key===r){return this._adj.map}o=function(t,e){if(t[0]<e[0]||t[0]===e[0]&&t[1]<e[1]){return t[0]+","+t[1]+","+e[0]+","+e[1]}else{return e[0]+","+e[1]+","+t[0]+","+t[1]}};l=new Map;for(a=0,u=e.length;a<u;++a){s=e[a];for(c=0,h=(f=t[s]).length;c<h;++c){d=f[c];for(g=0,p=d.length;g<p;++g){m=d[g];for(b=0,v=m.length-1;b<v;++b){y=b;i=o(m[y],m[y+1]);if(w=l.get(i)){w.push(s)}else{l.set(i,[s])}}}}}x={};for(a=0,u=e.length;a<u;++a){s=e[a];x[s]=t[s].map(k)}this._adj={key:r,map:x};return x;function k(t){return t.map(function(i){return function(){var t,e,n=[];for(t=0,e=i.length-1;t<e;++t){n.push(t)}return n}().map(function(t){return(l.get(o(i[t],i[t+1]))||[]).find(function(t){return t!==s})||null})})}},draw3d:function(t){var e,n,i,r,o,u,l,a,s,c,f,h,d,g,p,m,b,v,y,w,x,k,M,_,A,j,P,z,S=this;e=this.cfg;for(n in i=this.node){r=i[n];r.g.style.display="none";r.bubble.style.display="none";r.line.style.display="none"}for(n in i=this.outline){o=i[n];o.style.display="none"}u=this.local.viewParam();l=this.local.shape();a=this.local.units();s=toRgb(e.heat.empty,qt);c=/^#[0-9a-f]{3}([0-9a-f]{3})?$/i.test(((e.background||"")+"").trim())?toRgb(e.background,qt):[255,255,255];f={};for(h=0,d=a.length;h<d;++h){g=a[h];p=this.local.color(g)||s;m=this.local.picked(g);f[g.code]={h:this.local.height(g)*u.hmax,fill:p.map(I),polys:l.polys[g.code]}}this.s3adj=this.local.adjacency(Object.fromEntries(a.map(function(t){return[t.code,l.polys[t.code]]})));this.s3outline=l.outline;b=a.map(function(t){return Math.sqrt(l.ms[t.code].area||0)}).filter(function(t){return t>0}).sort(function(t,e){return t-e});this.s3band=(i=(b[Math.floor(b.length/2)]||this.geo.W)*.35)>(v=this.geo.W/400)?i:v;if(t&&this.s3){return this.local.render3d()}y=this.s3||{};w=this.s3view||u;x=function(t,n){return t.reduce(function(t,e){return t+e[n]},0)/t.length};k={};for(n in f){M=f[n];_=y[n];g=this.geo.feat[n];if(!_){A=g.level==="village"?y[g.tcode]:null;j=g.level==="town"?(this.geo.villOf[n]||[]).map(O).filter(q):[];_=A?{h:A.h,fill:A.fill}:j.length?{h:x(j,"h"),fill:[0,1,2].map(E)}:{h:0,fill:M.fill}}P=_.polys&&_.polys!==M.polys&&_.polys.length===M.polys.length&&_.polys.every(R);k[n]={h:_.h,fill:_.fill,polys:P?_.polys:null}}z=function(t,e,n){return t+(e-t)*n};return this.anim.tween(this._t3,{"data-t":function(o){var t,e,l,n,i;S.s3={};for(t in e=f){l=e[t];n=k[t];i=!n.polys||o>=1?l.polys:n.polys.map(r);S.s3[t]={h:z(n.h,l.h,o),fill:l.fill.map(a),polys:i}}S.s3view=import$(import$({},u),Object.fromEntries(["cx","cy","s","ox","oy"].map(function(t){return[t,z(w[t],u[t],o)]})));S.local.render3d();return o;function r(t,r){return t.map(function(t,i){return t.map(function(t,e){var n;n=l.polys[r][i][e];return[z(t[0],n[0],o),z(t[1],n[1],o)]})})}function a(t,e){return z(n.fill[e],t,o)}}},{duration:t?0:350});function I(t,e){return t*m+c[e]*(1-m)}function O(t){return y[t.code]}function q(t){return t}function E(e){return x(j.map(function(t){return{v:t.fill[e]}}),"v")}function R(t,n){return t.length===M.polys[n].length&&t.every(function(t,e){return t.length===M.polys[n][e].length})}},render3d:function(){var n,t,i,C,W,e,r,o,l,a,L,N,u,s,c,B,f,h,d,g,p,m,b,v,y,F,w,x,k,M,Z,_,H,X,A,G,j,T,P,z,S,I,O,q,E,V,J,K,U,Y,D,Q,tt,et,nt,it,rt,ot,R,lt,at,ut,st,ct,ft,ht,dt,gt,pt,mt,bt,vt,yt,wt,xt,kt,Mt,$,_t,At,jt,Pt=this;n=this.s3;if(!n){return}t=this.cfg;i=this.local.mkview(this.s3view);C=this.s3adj;W=this.local.shape();this.g.solid.style.display="";r=[];for(o in n){r.push(o)}e=r;l=function(t){return t[0].toFixed(2)+","+t[1].toFixed(2)};a=function(t,e){return i.prj(t[0],t[1],e)};L=function(t,e,n,i){return"M"+[a(t,n),a(e,n),a(e,i),a(t,i)].map(l).join("L")+"Z"};N=function(t,e,n){return[t[0]+(e[0]-t[0])*n,t[1]+(e[1]-t[1])*n]};u={};s=[Infinity,-Infinity],c=s[0],B=s[1];for(f=0,h=e.length;f<h;++f){d=e[f];s=[Infinity,-Infinity],g=s[0],p=s[1];m=[];for(b=0,v=(s=n[d].polys).length;b<v;++b){y=s[b];F=[];for(w=0,x=y.length;w<x;++w){k=w;M=y[w];Z=[];for(_=0,H=M.length;_<H;++_){X=M[_];A=i.rot(X[0],X[1]);if(A[1]<g){g=A[1]}if(A[1]>p){p=A[1]}Z.push(A)}F.push({r:Z,sgn:(ringArea(Z)>0?1:-1)*(k>0?-1:1)})}m.push(F)}u[d]={rr:m,lo:g,hi:p};if(g<c){c=g}if(p>B){B=p}}if(t.extrude.base.enabled){G=toRgb(t.extrude.base.color,qt);s=["",""],j=s[0],T=s[1];for(f=0,h=(s=this.s3outline).length;f<h;++f){y=s[f];for(b=0,v=y.length;b<v;++b){k=b;M=y[b];if(M.length<4){continue}m=M.map(zt);j+="M"+m.slice(0,-1).map(St).join("L")+"Z";P=(ringArea(m)>0?1:-1)*(k>0?-1:1);for(w=0,z=m.length-1;w<z;++w){S=w;I=[m[S],m[S+1]],O=I[0],q=I[1];if(P*(O[0]-q[0])>0){T+=L(O,q,-i.thick,0)}}}}this.base.wall.setAttribute("d",T);this.base.wall.setAttribute("fill",rgbStr(G,.8));this.base.top.setAttribute("d",j);this.base.top.setAttribute("fill",rgbStr(G));this.g.base.style.display=""}else{this.g.base.style.display="none"}E=this.s3band;V=e.length?Math.floor((B-c)/E)+1:0;r=[];for(f=0;f<V;++f){K=f;r.push([])}J=r;for(f=0,h=e.length;f<h;++f){d=e[f];A=u[d];for(b=Math.floor((A.lo-c)/E),z=Math.floor((A.hi-c)/E);b<=z;++b){o=b;J[o].push(d)}}U=function(t,e,n){var i,r,o,l,a,u,s,c,f;i=[];for(r=0,o=t.length;r<o;++r){l=r;a=t[r];u=t[(l+1)%t.length];s=[n(a[1]),n(u[1])],c=s[0],f=s[1];if(c){i.push(a)}if(c!==f){i.push(N(a,u,(e-a[1])/(u[1]-a[1])))}}return i};Y=function(t,e,n){var i;i=U(t.slice(0,-1),e,function(t){return t>=e});if(i.length<3){return null}i=U(i,n,function(t){return t<=n});if(i.length<3){return null}else{return i}};D=function(t,e,n,i){var r,o,l,a,u,s;r=e[1]-t[1];if(!r){return t[1]>=n&&t[1]<i?[0,1]:null}o=[(n-t[1])/r,(i-t[1])/r],l=o[0],a=o[1];if(l>a){o=[a,l],l=o[0],a=o[1]}o=[l>0?l:0,a<1?a:1],u=o[0],s=o[1];if(u<s){return[u,s]}else{return null}};Q=this.pool;tt={i:0};et=function(t,e,n){var i,r,o;i=Q[tt.i];if(!i){i=Q[tt.i]=mk(Pt.g.solid,"path");i._a={}}tt.i++;e.d=t;for(r in e){o=e[r];if(i._a[r]!==o){i._a[r]=o;i.setAttribute(r,o)}}return i.__data__=n};nt=1-t.extrude.shade;for(f=0,h=J.length;f<h;++f){o=f;it=J[f];if(!it.length){continue}rt=c+o*E;ot=rt+E;it.sort(It);for(b=0,v=it.length;b<v;++b){d=it[b];R=n[d];A=u[d];lt=this.geo.feat[d];at=A.lo>=rt&&A.hi<=ot;s=["","","",""],ut=s[0],st=s[1],j=s[2],ct=s[3];for(w=0,x=(s=A.rr).length;w<x;++w){ft=w;y=s[w];for(_=0,H=y.length;_<H;++_){k=_;I=y[_],M=I.r,P=I.sgn;if(M.length<4){continue}ht=at?M.slice(0,-1):Y(M,rt,ot);if(ht){j+="M"+ht.map(Ot).join("L")+"Z"}dt=C[d][ft][k];for(gt=0,z=M.length-1;gt<z;++gt){S=gt;I=[M[S],M[S+1]],O=I[0],q=I[1];pt=at?[0,1]:D(O,q,rt,ot);if(!pt){continue}I=[N(O,q,pt[0]),N(O,q,pt[1])],mt=I[0],bt=I[1];ct+="M"+l(a(mt,R.h))+"L"+l(a(bt,R.h));I=[P*(q[1]-O[1]),P*(O[0]-q[0])],vt=I[0],yt=I[1];if(yt<=0){continue}wt=dt[S]&&n[dt[S]]?n[dt[S]].h:0;if(R.h-wt<1e-6){continue}if(vt>0){st+=L(mt,bt,wt,R.h)}else{ut+=L(mt,bt,wt,R.h)}}}}xt=this.node[d].g.__data__;for(w=0,x=(s=[[ut,nt],[st,nt*nt]]).length;w<x;++w){I=s[w],kt=I[0],Mt=I[1];if(kt){$=rgbStr(R.fill,Mt);et(kt,{fill:$,stroke:$,"stroke-width":.5,"stroke-linejoin":"round","pointer-events":"visiblePainted"},xt)}}if(j){$=rgbStr(R.fill);et(j,{fill:$,stroke:$,"stroke-width":.6,"stroke-linejoin":"round","pointer-events":"visiblePainted"},xt)}if(ct){et(ct,{fill:"none",stroke:lt.level==="town"?t.border.color:t.border.village.color,"stroke-width":lt.level==="town"?t.border.width:t.border.village.width,"stroke-linejoin":t.border.linejoin,"pointer-events":"none"},xt)}}}for(f=0,h=(s=Q.splice(tt.i)).length;f<h;++f){_t=s[f];_t.remove()}At=function(t){var e;if(n[t.code]){return n[t.code].h}e=(Pt.geo.villOf[t.code]||[]).map(function(t){return n[t.code]}).filter(function(t){return t});if(e.length){return e.reduce(function(t,e){return t+e.h},0)/e.length}else{return 0}};jt=function(t){var e;e=W.ms[t.code];return i.pt(e.label[0],e.label[1],At(t))};this.local.labels({units:e.map(function(t){return Pt.geo.feat[t]}),dur:0,drawn:{},fresh:function(){return true},pos:jt,start:jt,depth:function(t){var e;e=W.ms[t.code];return i.rot(e.label[0],e.label[1])[1]}});return this.prev={is3d:true,v:i,h:function(t){if(n[t]){return n[t].h}else{return 0}},shown:{}};function zt(t){return i.rot(t[0],t[1])}function St(t){return l(a(t,0))}function It(t,e){return n[t].h-n[e].h||u[t].lo+u[t].hi-(u[e].lo+u[e].hi)}function Ot(t){return l(a(t,R.h))}},bubbles:function(t,e){var l,n,i,r,a=this;l=this.cfg.bubble;n=t.map(function(t){var e,n,i,r,o;e=a.rec[t.code]||{};n=e.size!=null?e.size:e.value;i=a.domOf(t);r=a.geo.feat[t.code];o=n!=null&&i.smax?Math.sqrt(Math.abs(n)/i.smax)*i.rmax*l.scale:0;return{code:t.code,tx:r.c[0],ty:r.c[1],x:r.c[0],y:r.c[1],r:o}});i=JSON.stringify([l.overlap,l.padding,this.box.width].concat(n.map(function(t){return[t.code,t.r.toFixed(3)]})));if(this._bubble&&this._bubble.key===i){return this._bubble.map}r=this.local.view().s;if(!l.overlap){relax(n.filter(function(t){return t.r>0}),l.padding/r)}this._bubble={key:i,map:Object.fromEntries(n.map(function(t){return[t.code,t]}))};return this._bubble.map},drawScale:function(){var i,t,e,n,r,o,l,a,u,s,c,f,h,d,g,p,m,b,v,y,w,x,k,M,_,A,j,P,z,S,I,O,q,E,R,$,C=[];i=this.g.scale;i.textContent="";if(!this.showScale){return}t=this.local.units();e=t.length&&t.every(function(t){return t.level==="village"});n=this.cfg.village.domain!=="shared"&&(e||this.local.focus())?this.geo.villages[0]:this.geo.towns[0];r=this.domOf(n).scale;if(!r){return}o=this.layout.getBox("scale");l=this.cfg.legend.position==="bottom";a=K.from(this.cfg.legend.format||".3s");u=(this.binding.value||{}).unit||"";s="tmap-grad-"+Math.random().toString(36).substring(2);c=mk(i,"defs");f=mk(c,"linearGradient");f.setAttribute("id",s);if(l){f.setAttribute("x2","100%")}else{f.setAttribute("x2","0");f.setAttribute("y1","100%");f.setAttribute("y2","0")}h=Math.round(this.cfg.heat.steps||0);d=h>1?h:24;for(g=0;g<d;++g){p=g;for(m=0,v=(b=h>1?[p/d,(p+1)/d]:[p/(d-1)]).length;m<v;++m){y=b[m];w=mk(f,"stop");w.setAttribute("offset",(y*100).toFixed(2)+"%");x=h>1?p/(h-1):p/(d-1);w.setAttribute("stop-color",rgbStr(r.color(x)))}}k=10;M=l?o.width-20:o.height-30;M=M>20?M:20;_=mk(i,"rect");_.setAttribute("fill","url(#"+s+")");A=r.inv;j=function(t){var e;e=!r.div?r.tlo+(r.thi-r.tlo)*t:t<.5?r.tlo+(r.tc-r.tlo)*t*2:r.tc+(r.thi-r.tc)*(t-.5)*2;return A(e)};P=[0,.5,1];z=function(t,e){var n;n=mk(i,"text");n.textContent=e;n.setAttribute("font-size","0.75em");n.setAttribute("fill","currentColor");if(l){n.setAttribute("x",10+M*t);n.setAttribute("y",k+14);return n.setAttribute("text-anchor","middle")}else{n.setAttribute("x",k+4);n.setAttribute("y",10+M*(1-t));return n.setAttribute("dominant-baseline","central")}};b=l?[10,0,M,k]:[0,10,k,M],S=b[0],I=b[1],O=b[2],q=b[3];for(E in b={x:S,y:I,width:O,height:q}){R=b[E];_.setAttribute(E,R)}for(g=0,v=P.length;g<v;++g){$=P[g];C.push(z($,a(j($))+""+($===1?u:"")))}return C},tip:function(t){var e,n,i,r,o,l,a,u,s,c,f,h;e=this.rec[t.code]||{};n=K.from(this.cfg.tip.format||".3s");i=function(t,e){if(t!=null&&isFinite(t)){return n(t)+""+((e||{}).unit||"")}else{return"-"}};r=t.level==="village"?t.village:t.town;o=[];if(this.binding.value){o.push((this.binding.value.name||this.binding.value.key)+": "+i(e.value,this.binding.value))}if(this.binding.size&&this.cfg.mode!=="map"){o.push((this.binding.size.name||this.binding.size.key)+": "+i(e.size,this.binding.size))}if(this.binding.cat&&e.cat!=null){o.push((this.binding.cat.name||this.binding.cat.key)+": "+e.cat)}if(this.local.isPie()){l=(e.parts||[]).reduce(function(t,e){return t+(e||0)},0);for(a=0,s=(u=this.binding.parts).length;a<s;++a){c=a;f=u[a];h=(e.parts||[])[c];o.push((f.name||f.key)+": "+i(h,f)+(l&&h!=null?" ("+(h/l*100).toFixed(1)+"%)":""))}}return{group:t.level==="village"?t.town:"",name:r+(e.agg?" ( "+S(this.geo.national?"aggregated-town":"aggregated")+" )":""),value:o[0]||"-",valueAlt:o.slice(1).join("\n")}},click:function(t,e){var i,n,r,o,l,a,u,s;i=t&&t.shiftKey;n=e.level==="town"?e:this.geo.feat[e.tcode];if(e.level==="town"&&this.cfg.village.mode==="click"&&(this.geo.villOf[e.code]||[]).length){if(!i){this.expanded={}}this.expanded[e.code]=true}r=function(e,n){var t;e=(e||[]).slice();n=[].concat(n);t=n.every(function(t){return in$(t,e)});if(i){if(t){return e.filter(function(t){return!in$(t,n)})}else{return Array.from(new Set(e.concat(n)))}}else if(t&&e.length===n.length){return[]}else{return n}};o=((this.binding.town||{}).filter||{}).value;l=((this.binding.village||{}).filter||{}).value;a=this.rec[e.code]||{};u=a.keys||(this.rec[n.code]||{}).keys||[];s={};if(e.level==="village"&&this.cfg.filterLevel==="village"&&this.binding.village&&a.vname!=null){l=r(l,a.vname);o=l.length?Array.from(new Set((o||[]).concat(u))):[];s.village=l.length?{type:"index",value:l}:undefined}else if(u.length){o=r(o,u);s.village=undefined;if(!i&&!o.length){delete this.expanded[n.code]}}else{return this.render()}s.town=o&&o.length?{type:"index",value:o}:undefined;if(!this.binding.town){return this.render()}return this.filter(s,true)},reset:function(){var t,e;t=function(){var t=[];for(e in this.expanded){t.push(e)}return t}.call(this).length||(this.binding.town||{}).filter||(this.binding.village||{}).filter;this.expanded={};if(!t){return}if(this.binding.town){return this.filter({town:undefined,village:undefined},true)}else{return this.render()}}}};function N(t){t[0]=(t[0]-b)*k;return t[1]=(t[1]-v)*k}})})})};function in$(t,e){var n=-1,i=e.length>>>0;while(++n<i)if(t===e[n])return true;return false}function import$(t,e){var n={}.hasOwnProperty;for(var i in e)if(n.call(e,i))t[i]=e[i];return t}</script><div plug="layout"><div class="pdl-layout"><div data-type="layout"><div class="pdl-cell" data-name="view"></div><div class="pdl-cell" data-name="legend"> </div><div class="pdl-cell" data-name="scale"><div></div></div></div><div data-type="render"></div></div></div></div>
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@makechart/twmapadv","version":"0.0.
|
|
1
|
+
{"name":"@makechart/twmapadv","version":"0.0.3","description":"","scripts":{"test":"mctest","test:serve":"mctest serve -o","test:dev":"mctest -l \"pdmaptw:../../../plotdb/projects/pdmaptw;@makechart/base:../base;@plotdb/chart:../../../plotdb/projects/chart;@plotdb/dash:../../../plotdb/projects/dash\"","test:dev:serve":"mctest serve -o -l \"pdmaptw:../../../plotdb/projects/pdmaptw;@makechart/base:../base;@plotdb/chart:../../../plotdb/projects/chart;@plotdb/dash:../../../plotdb/projects/dash\""},"keywords":[],"author":"zbryikt","license":"MIT","dependencies":{"@plotdb/srcbuild":"^0.0.69","fedep":"1.6.0","livescript":"^1.6.0"},"devDependencies":{"@makechart/viewer":"^0.0.5","d3-array":"^3.2.4","d3-geo":"^3.1.1","topojson-client":"^3.1.0","topojson-simplify":"^3.0.3"}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"source":"內政部戶政司 村里戶數、單一年齡人口 114年9月","head":["縣市","鄉鎮","人口","人口密度","性比例","男","女","0-14歲","15-64歲","65歲以上","高齡分級"],"units":{"人口":"人","人口密度":"人/km²","男":"人","女":"人","0-14歲":"人","15-64歲":"人","65歲以上":"人"},"rows":[["南投縣","全區",468657,114,103.3,238097,230560,47329,316257,105071,"超高齡 (20–25%)"],["嘉義市","全區",260749,4355,91.8,124776,135973,31633,177714,51402,"高齡 (14–20%)"],["嘉義縣","全區",474796,243,107.1,245535,229261,39436,322237,113123,"超高齡 (20–25%)"],["基隆市","全區",360429,2614,98.2,178621,181808,33586,247698,79145,"超高齡 (20–25%)"],["宜蘭縣","全區",449999,204,100.3,225385,224614,49552,308131,92316,"超高齡 (20–25%)"],["屏東縣","全區",783931,279,102.2,396146,387785,78498,536185,169248,"超高齡 (20–25%)"],["彰化縣","全區",1213351,973,102.9,615248,598103,139550,829776,244025,"超高齡 (20–25%)"],["新北市","全區",4046037,1954,94.2,1962651,2083386,438155,2812198,795684,"高齡 (14–20%)"],["新竹市","全區",455275,3650,97.4,224688,230587,69414,313251,72610,"高齡 (14–20%)"],["新竹縣","全區",597193,422,103.6,303875,293318,89020,419331,88842,"高齡 (14–20%)"],["桃園市","全區",2352683,1928,96.8,1157457,1195226,310808,1654216,387659,"高齡 (14–20%)"],["澎湖縣","全區",106768,788,104.7,54601,52167,10078,74579,22111,"超高齡 (20–25%)"],["臺中市","全區",2867537,1277,95.1,1397989,1469548,367941,2007842,491754,"高齡 (14–20%)"],["臺北市","全區",2442991,9033,89.1,1150846,1292145,294061,1565123,583807,"超高齡 (20–25%)"],["臺南市","全區",1854682,819,98.2,918769,935913,206436,1273449,374797,"超高齡 (20–25%)"],["臺東縣","全區",208769,58,103.5,106158,102611,22559,142966,43244,"超高齡 (20–25%)"],["花蓮縣","全區",313433,68,100.4,157047,156386,33899,212860,66674,"超高齡 (20–25%)"],["苗栗縣","全區",532053,291,105.6,273324,258729,60177,365440,106436,"超高齡 (20–25%)"],["連江縣","全區",13635,458,138.1,7909,5726,1297,10025,2313,"高齡 (14–20%)"],["金門縣","全區",139689,754,98.7,69387,70302,10804,101801,27084,"高齡 (14–20%)"],["雲林縣","全區",652874,465,105.6,335399,317475,68960,443056,140858,"超高齡 (20–25%)"],["高雄市","全區",2721500,905,95.7,1331173,1390327,295932,1866887,558681,"超高齡 (20–25%)"],["南投縣","南投市",96524,1340,98.5,47892,48632,11337,64957,20230,"超高齡 (20–25%)"],["南投縣","埔里鎮",75772,441,97.4,37379,38393,7653,51031,17088,"超高齡 (20–25%)"],["南投縣","草屯鎮",97445,935,99.6,48621,48824,11048,66509,19888,"超高齡 (20–25%)"],["南投縣","竹山鎮",50076,193,103.6,25486,24590,4621,33557,11898,"超高齡 (20–25%)"],["南投縣","集集鎮",9684,243,107.8,5024,4660,730,6533,2421,"超高齡 (≥25%)"],["南投縣","名間鄉",34731,437,111.2,18289,16442,2661,23787,8283,"超高齡 (20–25%)"],["南投縣","鹿谷鄉",15509,108,114.5,8278,7231,942,9958,4609,"超高齡 (≥25%)"],["南投縣","中寮鄉",12904,89,120.5,7053,5851,791,8517,3596,"超高齡 (≥25%)"],["南投縣","魚池鄉",14158,114,111,7449,6709,1066,9409,3683,"超高齡 (≥25%)"],["南投縣","國姓鄉",16089,78,117.3,8684,7405,972,10859,4258,"超高齡 (≥25%)"],["南投縣","水里鄉",15550,139,109.2,8117,7433,1248,9938,4364,"超高齡 (≥25%)"],["南投縣","信義鄉",14934,10,113.7,7946,6988,1997,10493,2444,"高齡 (14–20%)"],["南投縣","仁愛鄉",15281,12,106.4,7879,7402,2263,10709,2309,"高齡 (14–20%)"],["嘉義市","東區",116262,3885,90,55074,61188,13694,78155,24413,"超高齡 (20–25%)"],["嘉義市","西區",144487,4825,93.2,69702,74785,17939,99559,26989,"高齡 (14–20%)"],["嘉義縣","太保市",39832,598,101.5,20064,19768,4842,28543,6447,"高齡 (14–20%)"],["嘉義縣","朴子市",40071,800,100.2,20057,20014,4560,26741,8770,"超高齡 (20–25%)"],["嘉義縣","布袋鎮",23725,299,104.5,12123,11602,1481,16248,5996,"超高齡 (≥25%)"],["嘉義縣","大林鎮",29453,455,102.2,14890,14563,2599,19472,7382,"超高齡 (≥25%)"],["嘉義縣","民雄鄉",69965,822,103.4,35560,34405,6649,49050,14266,"超高齡 (20–25%)"],["嘉義縣","溪口鄉",12684,390,115.8,6806,5878,795,8267,3622,"超高齡 (≥25%)"],["嘉義縣","新港鄉",29113,439,111.7,15360,13753,2497,19373,7243,"超高齡 (20–25%)"],["嘉義縣","六腳鄉",20128,322,114.3,10736,9392,1090,12922,6116,"超高齡 (≥25%)"],["嘉義縣","東石鄉",21800,265,112.5,11543,10257,1282,14831,5687,"超高齡 (≥25%)"],["嘉義縣","義竹鄉",15858,201,109.5,8290,7568,935,10037,4886,"超高齡 (≥25%)"],["嘉義縣","鹿草鄉",13576,248,119.4,7388,6188,826,8533,4217,"超高齡 (≥25%)"],["嘉義縣","水上鄉",47239,673,106.2,24330,22909,3324,33309,10606,"超高齡 (20–25%)"],["嘉義縣","中埔鄉",41885,321,107.2,21671,20214,3202,28881,9802,"超高齡 (20–25%)"],["嘉義縣","竹崎鄉",32296,205,113,17132,15164,2511,21439,8346,"超高齡 (≥25%)"],["嘉義縣","梅山鄉",17194,144,112.5,9104,8090,1307,10985,4902,"超高齡 (≥25%)"],["嘉義縣","番路鄉",10632,94,114.3,5671,4961,660,7168,2804,"超高齡 (≥25%)"],["嘉義縣","大埔鄉",4169,24,103.3,2118,2051,313,2893,963,"超高齡 (20–25%)"],["嘉義縣","阿里山鄉",5176,11,108.4,2692,2484,563,3545,1068,"超高齡 (20–25%)"],["基隆市","中正區",51590,3706,100.8,25903,25687,3910,35683,11997,"超高齡 (20–25%)"],["基隆市","七堵區",52280,928,99.2,26039,26241,5016,36214,11050,"超高齡 (20–25%)"],["基隆市","暖暖區",38353,1672,98.8,19063,19290,3718,27078,7557,"高齡 (14–20%)"],["基隆市","仁愛區",39824,8724,96.1,19514,20310,5123,24792,9909,"超高齡 (20–25%)"],["基隆市","中山區",45699,4196,101.7,23040,22659,3422,32079,10198,"超高齡 (20–25%)"],["基隆市","安樂區",80003,4302,96.2,39219,40784,7795,55504,16704,"超高齡 (20–25%)"],["基隆市","信義區",52680,4960,96.3,25843,26837,4602,36348,11730,"超高齡 (20–25%)"],["宜蘭縣","宜蘭市",94742,3107,94.1,45934,48808,12442,63929,18371,"高齡 (14–20%)"],["宜蘭縣","羅東鎮",69093,6114,89.2,32570,36523,10345,44564,14184,"超高齡 (20–25%)"],["宜蘭縣","蘇澳鎮",36546,407,102.8,18524,18022,3267,24559,8720,"超高齡 (20–25%)"],["宜蘭縣","頭城鎮",27947,272,105.1,14322,13625,2724,19320,5903,"超高齡 (20–25%)"],["宜蘭縣","礁溪鄉",36625,363,105.1,18769,17856,3204,25596,7825,"超高齡 (20–25%)"],["宜蘭縣","壯圍鄉",24498,620,108.7,12757,11741,2047,17443,5008,"超高齡 (20–25%)"],["宜蘭縣","員山鄉",32251,227,110.7,16944,15307,2724,23017,6510,"超高齡 (20–25%)"],["宜蘭縣","冬山鄉",52984,704,101.8,26722,26262,5426,36576,10982,"超高齡 (20–25%)"],["宜蘭縣","五結鄉",41844,1036,101.3,21053,20791,3836,29794,8214,"高齡 (14–20%)"],["宜蘭縣","三星鄉",21388,242,116.2,11497,9891,1583,14893,4912,"超高齡 (20–25%)"],["宜蘭縣","大同鄉",5970,8,115.5,3200,2770,885,4245,840,"高齡 (14–20%)"],["宜蘭縣","南澳鄉",6111,9,102.5,3093,3018,1069,4195,847,"高齡化 (7–14%)"],["屏東縣","屏東市",191815,2897,95.4,93634,98181,21976,130146,39693,"超高齡 (20–25%)"],["屏東縣","潮州鎮",53791,1262,96.7,26447,27344,5460,37461,10870,"超高齡 (20–25%)"],["屏東縣","東港鎮",45959,1487,100.1,22994,22965,5582,31963,8414,"高齡 (14–20%)"],["屏東縣","恆春鎮",28879,204,102.3,14607,14272,3286,20212,5381,"高齡 (14–20%)"],["屏東縣","萬丹鄉",48653,819,106.5,25095,23558,5003,33642,10008,"超高齡 (20–25%)"],["屏東縣","長治鄉",29278,638,104.8,14985,14293,2489,20295,6494,"超高齡 (20–25%)"],["屏東縣","麟洛鄉",10418,747,104.5,5324,5094,595,7007,2816,"超高齡 (≥25%)"],["屏東縣","九如鄉",21452,496,103.7,10923,10529,1961,14979,4512,"超高齡 (20–25%)"],["屏東縣","里港鄉",24987,358,101.3,12573,12414,2882,16899,5206,"超高齡 (20–25%)"],["屏東縣","鹽埔鄉",23237,392,108,12065,11172,1929,16180,5128,"超高齡 (20–25%)"],["屏東縣","高樹鄉",22025,233,111,11585,10440,1570,14224,6231,"超高齡 (≥25%)"],["屏東縣","萬巒鄉",18723,307,109,9766,8957,1713,12333,4677,"超高齡 (20–25%)"],["屏東縣","內埔鄉",52886,684,103.6,26905,25981,4725,36231,11930,"超高齡 (20–25%)"],["屏東縣","竹田鄉",15412,519,113.9,8208,7204,1014,10294,4104,"超高齡 (≥25%)"],["屏東縣","新埤鄉",9037,159,111.1,4757,4280,600,5997,2440,"超高齡 (≥25%)"],["屏東縣","枋寮鄉",22406,369,106.9,11574,10832,1956,14879,5571,"超高齡 (20–25%)"],["屏東縣","新園鄉",31809,699,106.9,16437,15372,2227,22591,6991,"超高齡 (20–25%)"],["屏東縣","崁頂鄉",14507,572,100.1,7258,7249,2613,8881,3013,"超高齡 (20–25%)"],["屏東縣","林邊鄉",15867,927,102.3,8025,7842,1306,10379,4182,"超高齡 (≥25%)"],["屏東縣","南州鄉",9613,510,104.5,4913,4700,577,6430,2606,"超高齡 (≥25%)"],["屏東縣","佳冬鄉",17363,536,105.9,8931,8432,1265,11614,4484,"超高齡 (≥25%)"],["屏東縣","琉球鄉",12036,1751,118.3,6523,5513,1004,8407,2625,"超高齡 (20–25%)"],["屏東縣","車城鄉",7728,129,113.8,4114,3614,566,5145,2017,"超高齡 (≥25%)"],["屏東縣","滿州鄉",6945,46,118.5,3766,3179,429,4870,1646,"超高齡 (20–25%)"],["屏東縣","枋山鄉",4906,271,107.8,2545,2361,328,3464,1114,"超高齡 (20–25%)"],["屏東縣","三地門鄉",7578,41,99.4,3778,3800,953,5433,1192,"高齡 (14–20%)"],["屏東縣","霧臺鄉",3169,10,102.6,1605,1564,325,2265,579,"高齡 (14–20%)"],["屏東縣","瑪家鄉",6642,107,100.2,3324,3318,783,4847,1012,"高齡 (14–20%)"],["屏東縣","泰武鄉",5183,42,104.6,2650,2533,735,3711,737,"高齡 (14–20%)"],["屏東縣","來義鄉",7284,45,98.1,3607,3677,980,5170,1134,"高齡 (14–20%)"],["屏東縣","春日鄉",4854,31,102.8,2460,2394,699,3405,750,"高齡 (14–20%)"],["屏東縣","獅子鄉",4815,15,104.3,2458,2357,475,3512,828,"高齡 (14–20%)"],["屏東縣","牡丹鄉",4674,27,97.7,2310,2364,492,3319,863,"高齡 (14–20%)"],["彰化縣","彰化市",221048,3354,96.1,108331,112717,28680,147447,44921,"超高齡 (20–25%)"],["彰化縣","鹿港鎮",82447,991,102.7,41780,40667,10961,56266,15220,"高齡 (14–20%)"],["彰化縣","和美鎮",86770,2267,103.2,44071,42699,9900,61265,15605,"高齡 (14–20%)"],["彰化縣","線西鄉",16062,519,106.5,8283,7779,1770,11241,3051,"高齡 (14–20%)"],["彰化縣","伸港鄉",38251,811,100.4,19168,19083,5180,26742,6329,"高齡 (14–20%)"],["彰化縣","福興鄉",44393,761,108.9,23143,21250,4708,31099,8586,"高齡 (14–20%)"],["彰化縣","秀水鄉",37443,1284,106.4,19302,18141,4436,26133,6874,"高齡 (14–20%)"],["彰化縣","花壇鄉",42904,1190,105.1,21984,20920,4061,30441,8402,"高齡 (14–20%)"],["彰化縣","芬園鄉",21438,559,110.3,11246,10192,1817,14727,4894,"超高齡 (20–25%)"],["彰化縣","員林市",122370,3097,96.6,60132,62238,16910,81987,23473,"高齡 (14–20%)"],["彰化縣","溪湖鎮",52909,1701,102.3,26750,26159,7409,35855,9645,"高齡 (14–20%)"],["彰化縣","田中鎮",38383,1111,103.9,19560,18823,3714,26027,8642,"超高齡 (20–25%)"],["彰化縣","大村鄉",39008,1278,103.6,19845,19163,4105,27925,6978,"高齡 (14–20%)"],["彰化縣","埔鹽鄉",30213,772,111.3,15914,14299,2631,21076,6506,"超高齡 (20–25%)"],["彰化縣","埔心鄉",33154,1576,105.6,17025,16129,3084,23708,6362,"高齡 (14–20%)"],["彰化縣","永靖鄉",34281,1685,106.7,17697,16584,3556,23636,7089,"超高齡 (20–25%)"],["彰化縣","社頭鄉",40352,1121,105.8,20748,19604,4225,27925,8202,"超高齡 (20–25%)"],["彰化縣","二水鄉",13277,372,111.1,6989,6288,924,8679,3674,"超高齡 (≥25%)"],["彰化縣","北斗鎮",33189,1676,100.4,16631,16558,4418,22307,6464,"高齡 (14–20%)"],["彰化縣","二林鎮",46660,505,105.8,23982,22678,4331,31746,10583,"超高齡 (20–25%)"],["彰化縣","田尾鄉",25361,1024,106.9,13103,12258,2434,17707,5220,"超高齡 (20–25%)"],["彰化縣","埤頭鄉",28021,658,106.7,14466,13555,2799,19085,6137,"超高齡 (20–25%)"],["彰化縣","芳苑鄉",29957,206,112.8,15878,14079,2438,20095,7424,"超高齡 (20–25%)"],["彰化縣","大城鄉",14210,149,117.5,7678,6532,878,9395,3937,"超高齡 (≥25%)"],["彰化縣","竹塘鄉",13948,332,111.2,7343,6605,1775,8624,3549,"超高齡 (≥25%)"],["彰化縣","溪州鄉",27302,393,108.4,14199,13103,2406,18638,6258,"超高齡 (20–25%)"],["新北市","板橋區",550256,25800,93.3,265580,284676,65350,373362,111544,"超高齡 (20–25%)"],["新北市","三重區",383035,21255,95.1,186670,196365,38605,266453,77977,"超高齡 (20–25%)"],["新北市","中和區",404507,20773,92.2,194033,210474,36658,277816,90033,"超高齡 (20–25%)"],["新北市","永和區",211631,34290,89,99634,111997,23496,136816,51319,"超高齡 (20–25%)"],["新北市","新莊區",421669,20343,93.9,204189,217480,53501,296251,71917,"高齡 (14–20%)"],["新北市","新店區",307003,2528,91.1,146345,160658,25822,208386,72795,"超高齡 (20–25%)"],["新北市","樹林區",177602,5552,98.1,87969,89633,20838,125317,31447,"高齡 (14–20%)"],["新北市","鶯歌區",89581,4092,99.5,44675,44906,10559,64369,14653,"高齡 (14–20%)"],["新北市","三峽區",115077,606,98.5,57116,57961,14261,81209,19607,"高齡 (14–20%)"],["新北市","淡水區",206758,2823,89.9,97907,108851,20697,145130,40931,"高齡 (14–20%)"],["新北市","汐止區",212788,2957,93.8,103000,109788,19014,153549,40225,"高齡 (14–20%)"],["新北市","瑞芳區",35751,494,101.9,18044,17707,2702,24624,8425,"超高齡 (20–25%)"],["新北市","土城區",242434,8080,95.1,118162,124272,27414,172180,42840,"高齡 (14–20%)"],["新北市","蘆洲區",196745,25441,95.2,95937,100808,22210,141975,32560,"高齡 (14–20%)"],["新北市","五股區",94510,2747,98.7,46952,47558,10257,69638,14615,"高齡 (14–20%)"],["新北市","泰山區",78101,4309,96.3,38317,39784,9194,55787,13120,"高齡 (14–20%)"],["新北市","林口區",138017,2537,93.6,66725,71292,23774,94157,20086,"高齡 (14–20%)"],["新北市","深坑區",23688,1129,98.7,11765,11923,1893,16912,4883,"超高齡 (20–25%)"],["新北市","石碇區",6939,49,120.5,3792,3147,382,4520,2037,"超高齡 (≥25%)"],["新北市","坪林區",6184,37,115.7,3317,2867,347,3843,1994,"超高齡 (≥25%)"],["新北市","三芝區",22125,327,105.7,11371,10754,1602,15101,5422,"超高齡 (20–25%)"],["新北市","石門區",10024,189,109.5,5239,4785,633,7046,2345,"超高齡 (20–25%)"],["新北市","八里區",43448,1091,97.7,21473,21975,4325,31425,7698,"高齡 (14–20%)"],["新北市","平溪區",3936,55,128.8,2216,1720,137,2388,1411,"超高齡 (≥25%)"],["新北市","雙溪區",7477,51,119.3,4067,3410,371,4646,2460,"超高齡 (≥25%)"],["新北市","貢寮區",10498,103,102.7,5319,5179,447,7200,2851,"超高齡 (≥25%)"],["新北市","金山區",19788,414,97.5,9768,10020,1423,14114,4251,"超高齡 (20–25%)"],["新北市","萬里區",20301,319,98.5,10072,10229,1408,13850,5043,"超高齡 (20–25%)"],["新北市","烏來區",6164,18,94.6,2997,3167,835,4134,1195,"高齡 (14–20%)"],["新竹市","東區",221997,6460,97.5,109577,112420,41125,148236,32636,"高齡 (14–20%)"],["新竹市","北區",153811,6508,95,74946,78865,19728,107045,27038,"高齡 (14–20%)"],["新竹市","香山區",79467,1191,102.2,40165,39302,8561,57970,12936,"高齡 (14–20%)"],["新竹縣","竹北市",220662,4372,98.6,109566,111096,44566,154550,21546,"高齡化 (7–14%)"],["新竹縣","竹東鎮",98074,1829,101.2,49319,48755,12629,68956,16489,"高齡 (14–20%)"],["新竹縣","新埔鎮",33655,465,114.1,17938,15717,2678,23474,7503,"超高齡 (20–25%)"],["新竹縣","關西鎮",26063,208,116.5,14022,12041,2193,17512,6358,"超高齡 (20–25%)"],["新竹縣","湖口鄉",84815,1458,101.4,42693,42122,11591,60427,12797,"高齡 (14–20%)"],["新竹縣","新豐鄉",59845,1197,105,30659,29186,8509,42834,8502,"高齡 (14–20%)"],["新竹縣","芎林鄉",20433,511,112.4,10812,9621,1651,14517,4265,"超高齡 (20–25%)"],["新竹縣","橫山鄉",11886,182,116.9,6407,5479,957,7841,3088,"超高齡 (≥25%)"],["新竹縣","北埔鄉",8334,156,121.1,4565,3769,651,5557,2126,"超高齡 (≥25%)"],["新竹縣","寶山鄉",14630,227,116.8,7883,6747,1103,10716,2811,"高齡 (14–20%)"],["新竹縣","峨眉鄉",4984,107,122.1,2740,2244,310,3150,1524,"超高齡 (≥25%)"],["新竹縣","尖石鄉",9422,18,108.8,4909,4513,1656,6656,1110,"高齡化 (7–14%)"],["新竹縣","五峰鄉",4390,21,116.5,2362,2028,526,3141,723,"高齡 (14–20%)"],["桃園市","桃園區",477988,13875,92.2,229326,248662,65525,334489,77974,"高齡 (14–20%)"],["桃園市","中壢區",438903,5754,94.7,213522,225381,59687,307606,71610,"高齡 (14–20%)"],["桃園市","大溪區",94014,892,102.5,47594,46420,11014,64742,18258,"高齡 (14–20%)"],["桃園市","楊梅區",182775,2034,99.2,91006,91769,24283,129467,29025,"高齡 (14–20%)"],["桃園市","蘆竹區",170615,2275,96.7,83861,86754,23150,122921,24544,"高齡 (14–20%)"],["桃園市","大園區",89122,987,102.2,45047,44075,11797,63409,13916,"高齡 (14–20%)"],["桃園市","龜山區",187668,2621,96.4,92136,95532,22686,134403,30579,"高齡 (14–20%)"],["桃園市","八德區",215697,6368,97.4,106411,109286,29227,150736,35734,"高齡 (14–20%)"],["桃園市","龍潭區",127511,1675,98.3,63210,64301,15737,88187,23587,"高齡 (14–20%)"],["桃園市","平鎮區",228291,5241,97.1,112481,115810,30598,159672,38021,"高齡 (14–20%)"],["桃園市","新屋區",49741,556,111.9,26262,23479,5373,33831,10537,"超高齡 (20–25%)"],["桃園市","觀音區",77143,800,106.1,39720,37423,9703,55646,11794,"高齡 (14–20%)"],["桃園市","復興區",13215,39,108.6,6881,6334,2028,9107,2080,"高齡 (14–20%)"],["澎湖縣","馬公市",63437,1814,102.7,32143,31294,6625,44738,12074,"高齡 (14–20%)"],["澎湖縣","湖西鄉",16107,463,108.8,8393,7714,1275,11460,3372,"超高齡 (20–25%)"],["澎湖縣","白沙鄉",9985,434,105.7,5131,4854,872,6850,2263,"超高齡 (20–25%)"],["澎湖縣","西嶼鄉",8052,409,105,4124,3928,604,5280,2168,"超高齡 (≥25%)"],["澎湖縣","望安鄉",5290,339,115.4,2834,2456,381,3530,1379,"超高齡 (≥25%)"],["澎湖縣","七美鄉",3897,523,102.9,1976,1921,321,2721,855,"超高齡 (20–25%)"],["臺中市","中區",18011,19584,95.3,8790,9221,3322,10571,4118,"超高齡 (20–25%)"],["臺中市","東區",77602,11482,96,38003,39599,8448,53968,15186,"高齡 (14–20%)"],["臺中市","南區",128307,16183,90.3,60869,67438,13979,93812,20516,"高齡 (14–20%)"],["臺中市","西區",113329,17810,88,53051,60278,15526,74391,23412,"超高齡 (20–25%)"],["臺中市","北區",143502,18968,89.6,67806,75696,15077,98001,30424,"超高齡 (20–25%)"],["臺中市","西屯區",237919,5943,90.2,112800,125119,32932,168380,36607,"高齡 (14–20%)"],["臺中市","南屯區",185951,6102,89.7,87927,98024,27263,133384,25304,"高齡化 (7–14%)"],["臺中市","北屯區",316894,5126,89.6,149789,167105,44108,223409,49377,"高齡 (14–20%)"],["臺中市","豐原區",161923,3882,96,79295,82628,21128,110023,30772,"高齡 (14–20%)"],["臺中市","東勢區",46648,432,102.9,23657,22991,4178,30773,11697,"超高齡 (≥25%)"],["臺中市","大甲區",73201,1230,100,36600,36601,9884,49366,13951,"高齡 (14–20%)"],["臺中市","清水區",90713,1127,103.6,46149,44564,11086,63240,16387,"高齡 (14–20%)"],["臺中市","沙鹿區",101330,2514,99.7,50594,50736,15722,71117,14491,"高齡 (14–20%)"],["臺中市","梧棲區",64880,1960,98.9,32257,32623,8964,46195,9721,"高齡 (14–20%)"],["臺中市","后里區",52795,921,100.8,26507,26288,6414,36430,9951,"高齡 (14–20%)"],["臺中市","神岡區",63450,1737,103.9,32337,31113,7175,44610,11665,"高齡 (14–20%)"],["臺中市","潭子區",109375,4223,96.5,53726,55649,13182,78502,17691,"高齡 (14–20%)"],["臺中市","大雅區",94803,2882,98.6,47056,47747,12943,67717,14143,"高齡 (14–20%)"],["臺中市","新社區",22605,275,106.8,11676,10929,1945,15290,5370,"超高齡 (20–25%)"],["臺中市","石岡區",13713,768,106.1,7060,6653,1207,9142,3364,"超高齡 (20–25%)"],["臺中市","外埔區",30865,732,103.8,15720,15145,3179,21940,5746,"高齡 (14–20%)"],["臺中市","大安區",17532,492,111,9223,8309,1480,12386,3666,"超高齡 (20–25%)"],["臺中市","烏日區",82162,1937,97.8,40625,41537,11026,58042,13094,"高齡 (14–20%)"],["臺中市","大肚區",55360,1443,102.8,28063,27297,6101,38940,10319,"高齡 (14–20%)"],["臺中市","龍井區",79137,1518,100.4,39639,39498,9816,57261,12060,"高齡 (14–20%)"],["臺中市","霧峰區",62769,651,102.9,31826,30943,6730,43106,12933,"超高齡 (20–25%)"],["臺中市","太平區",201112,1664,96.3,98680,102432,26161,142218,32733,"高齡 (14–20%)"],["臺中市","大里區",211173,7251,94.7,102688,108485,27959,148591,34623,"高齡 (14–20%)"],["臺中市","和平區",10476,10,113.8,5576,4900,1006,7037,2433,"超高齡 (20–25%)"],["臺北市","松山區",187465,21606,86.7,87077,100388,25782,115254,46429,"超高齡 (20–25%)"],["臺北市","信義區",201806,17894,88.4,94696,107110,20528,129060,52218,"超高齡 (≥25%)"],["臺北市","大安區",282653,24890,85.6,130340,152313,40550,169315,72788,"超高齡 (≥25%)"],["臺北市","中山區",212454,15102,84.2,97085,115369,22761,136760,52933,"超高齡 (20–25%)"],["臺北市","中正區",144477,19404,89.2,68108,76369,22309,88198,33970,"超高齡 (20–25%)"],["臺北市","大同區",116821,24351,91.3,55749,61072,13327,75734,27760,"超高齡 (20–25%)"],["臺北市","萬華區",169024,22589,93.3,81569,87455,14052,110809,44163,"超高齡 (≥25%)"],["臺北市","文山區",253991,8111,89.8,120194,133797,29819,168455,55717,"超高齡 (20–25%)"],["臺北市","南港區",111045,5048,93,53515,57530,12257,74530,24258,"超高齡 (20–25%)"],["臺北市","內湖區",268385,8382,89.4,126681,141704,35709,178496,54180,"超高齡 (20–25%)"],["臺北市","士林區",258695,4162,91.6,123655,135040,28776,165102,64817,"超高齡 (≥25%)"],["臺北市","北投區",236175,4082,90.5,112177,123998,28191,153410,54574,"超高齡 (20–25%)"],["臺南市","新營區",74627,1928,95.7,36484,38143,8752,49779,16096,"超高齡 (20–25%)"],["臺南市","鹽水區",23764,460,108.2,12350,11414,2068,15879,5817,"超高齡 (20–25%)"],["臺南市","白河區",25055,195,108.8,13053,12002,1791,15860,7404,"超高齡 (≥25%)"],["臺南市","柳營區",19897,322,108.6,10358,9539,1568,13261,5068,"超高齡 (≥25%)"],["臺南市","後壁區",20958,289,106.5,10807,10151,1351,13328,6279,"超高齡 (≥25%)"],["臺南市","東山區",18558,149,114.5,9907,8651,1245,11970,5343,"超高齡 (≥25%)"],["臺南市","麻豆區",42962,781,102.4,21731,21231,4483,28470,10009,"超高齡 (20–25%)"],["臺南市","下營區",21812,649,106,11225,10587,1857,14146,5809,"超高齡 (≥25%)"],["臺南市","六甲區",20930,313,106,10769,10161,1954,14042,4934,"超高齡 (20–25%)"],["臺南市","官田區",20563,284,104.3,10497,10066,1735,14327,4501,"超高齡 (20–25%)"],["臺南市","大內區",8460,119,115.3,4531,3929,488,5357,2615,"超高齡 (≥25%)"],["臺南市","佳里區",58348,1488,96.9,28714,29634,6478,39619,12251,"超高齡 (20–25%)"],["臺南市","學甲區",24413,447,105.1,12511,11902,2091,16612,5710,"超高齡 (20–25%)"],["臺南市","西港區",24847,739,101.7,12529,12318,2486,17177,5184,"超高齡 (20–25%)"],["臺南市","七股區",20580,144,107.1,10645,9935,1548,14059,4973,"超高齡 (20–25%)"],["臺南市","將軍區",17704,370,104.4,9043,8661,1062,11881,4761,"超高齡 (≥25%)"],["臺南市","北門區",9488,145,101.8,4786,4702,514,6591,2383,"超高齡 (≥25%)"],["臺南市","新化區",41974,676,102.2,21212,20762,4169,28678,9127,"超高齡 (20–25%)"],["臺南市","善化區",53800,1004,100.8,27008,26792,8426,36300,9074,"高齡 (14–20%)"],["臺南市","新市區",38302,758,101,19251,19051,5105,26790,6407,"高齡 (14–20%)"],["臺南市","安定區",29838,934,105.9,15346,14492,2955,21069,5814,"高齡 (14–20%)"],["臺南市","山上區",6838,247,111.9,3611,3227,562,4576,1700,"超高齡 (20–25%)"],["臺南市","玉井區",12709,169,106.7,6561,6148,948,8122,3639,"超高齡 (≥25%)"],["臺南市","楠西區",8436,77,112,4456,3980,474,5431,2531,"超高齡 (≥25%)"],["臺南市","南化區",7662,45,116.3,4120,3542,522,4895,2245,"超高齡 (≥25%)"],["臺南市","左鎮區",4075,56,133.7,2331,1744,176,2537,1362,"超高齡 (≥25%)"],["臺南市","仁德區",77504,1533,100.4,38832,38672,8032,54593,14879,"高齡 (14–20%)"],["臺南市","歸仁區",70530,1280,100.8,35412,35118,8574,49181,12775,"高齡 (14–20%)"],["臺南市","關廟區",33219,619,104.3,16960,16259,2870,22450,7899,"超高齡 (20–25%)"],["臺南市","龍崎區",3251,52,122.1,1787,1464,104,1996,1151,"超高齡 (≥25%)"],["臺南市","永康區",235942,5763,95.4,115193,120749,28242,169756,37944,"高齡 (14–20%)"],["臺南市","東區",180989,14000,89.9,85706,95283,24349,121218,35422,"高齡 (14–20%)"],["臺南市","南區",119431,4261,95.9,58463,60968,10327,81852,27252,"超高齡 (20–25%)"],["臺南市","北區",125412,12721,93.1,60453,64959,12901,86724,25787,"超高齡 (20–25%)"],["臺南市","安南區",204497,1743,100,102239,102258,27103,145052,32342,"高齡 (14–20%)"],["臺南市","安平區",71229,6225,87.7,33271,37958,7863,52235,11131,"高齡 (14–20%)"],["臺南市","中西區",76078,11909,92.8,36617,39461,11263,47636,17179,"超高齡 (20–25%)"],["臺東縣","臺東市",102810,907,97.1,50645,52165,12993,69834,19983,"高齡 (14–20%)"],["臺東縣","成功鎮",12824,87,110.3,6726,6098,990,8572,3262,"超高齡 (≥25%)"],["臺東縣","關山鎮",7785,129,105.9,4004,3781,825,5033,1927,"超高齡 (20–25%)"],["臺東縣","卑南鄉",16290,38,107.8,8449,7841,1353,11414,3523,"超高齡 (20–25%)"],["臺東縣","鹿野鄉",6945,87,111.9,3668,3277,442,4706,1797,"超高齡 (≥25%)"],["臺東縣","池上鄉",7563,95,104,3856,3707,691,4903,1969,"超高齡 (≥25%)"],["臺東縣","東河鄉",7737,36,119.4,4210,3527,481,5111,2145,"超高齡 (≥25%)"],["臺東縣","長濱鄉",6503,43,123.9,3599,2904,388,4285,1830,"超高齡 (≥25%)"],["臺東縣","太麻里鄉",10392,100,111.6,5481,4911,802,7160,2430,"超高齡 (20–25%)"],["臺東縣","大武鄉",5365,85,109.1,2799,2566,513,3707,1145,"超高齡 (20–25%)"],["臺東縣","綠島鄉",4340,304,117.7,2346,1994,350,3347,643,"高齡 (14–20%)"],["臺東縣","海端鄉",4335,5,106.7,2238,2097,649,3190,496,"高齡化 (7–14%)"],["臺東縣","延平鄉",3543,7,106.7,1829,1714,528,2599,416,"高齡化 (7–14%)"],["臺東縣","金峰鄉",3674,9,101.3,1849,1825,509,2646,519,"高齡 (14–20%)"],["臺東縣","達仁鄉",3419,11,115.2,1830,1589,346,2482,591,"高齡 (14–20%)"],["臺東縣","蘭嶼鄉",5244,111,100.5,2629,2615,699,3977,568,"高齡化 (7–14%)"],["花蓮縣","花蓮市",97077,3130,91.2,46303,50774,12659,64303,20115,"超高齡 (20–25%)"],["花蓮縣","鳳林鎮",10191,85,108.2,5297,4894,978,6223,2990,"超高齡 (≥25%)"],["花蓮縣","玉里鎮",21360,101,110.1,11193,10167,1883,14129,5348,"超高齡 (≥25%)"],["花蓮縣","新城鄉",20506,702,100.6,10283,10223,2134,14707,3665,"高齡 (14–20%)"],["花蓮縣","吉安鄉",83200,1319,98.3,41245,41955,7764,58387,17049,"超高齡 (20–25%)"],["花蓮縣","壽豐鄉",16709,80,111.7,8815,7894,1351,11240,4118,"超高齡 (20–25%)"],["花蓮縣","光復鄉",11381,86,111.3,5994,5387,808,7304,3269,"超高齡 (≥25%)"],["花蓮縣","豐濱鄉",4088,26,127.9,2294,1794,291,2711,1086,"超高齡 (≥25%)"],["花蓮縣","瑞穗鄉",10428,67,114.6,5568,4860,829,6668,2931,"超高齡 (≥25%)"],["花蓮縣","富里鄉",9419,55,113.4,5005,4414,818,6082,2519,"超高齡 (≥25%)"],["花蓮縣","秀林鄉",17166,11,103.3,8721,8445,2690,12420,2056,"高齡化 (7–14%)"],["花蓮縣","萬榮鄉",6050,9,109.8,3166,2884,802,4459,789,"高齡化 (7–14%)"],["花蓮縣","卓溪鄉",5858,6,117.4,3163,2695,892,4227,739,"高齡化 (7–14%)"],["苗栗縣","苗栗市",85954,2277,97.7,42487,43467,10005,57497,18452,"超高齡 (20–25%)"],["苗栗縣","苑裡鎮",43341,622,108.5,22552,20789,4250,30559,8532,"高齡 (14–20%)"],["苗栗縣","通霄鎮",30692,269,112.6,16254,14438,2533,20594,7565,"超高齡 (20–25%)"],["苗栗縣","竹南鎮",91431,2192,100.8,45905,45526,13818,64064,13549,"高齡 (14–20%)"],["苗栗縣","頭份市",108269,2041,101.6,54569,53700,15047,76284,16938,"高齡 (14–20%)"],["苗栗縣","後龍鎮",33623,389,111.5,17727,15896,3128,23411,7084,"超高齡 (20–25%)"],["苗栗縣","卓蘭鎮",14549,188,109.2,7594,6955,1104,9517,3928,"超高齡 (≥25%)"],["苗栗縣","大湖鄉",12396,136,114.7,6622,5774,946,8200,3250,"超高齡 (≥25%)"],["苗栗縣","公館鄉",30555,425,108.6,15904,14651,2971,20742,6842,"超高齡 (20–25%)"],["苗栗縣","銅鑼鄉",16127,206,112.2,8528,7599,1482,10764,3881,"超高齡 (20–25%)"],["苗栗縣","南庄鄉",8596,53,120.6,4700,3896,614,5736,2246,"超高齡 (≥25%)"],["苗栗縣","頭屋鄉",9408,182,115,5032,4376,561,6380,2467,"超高齡 (≥25%)"],["苗栗縣","三義鄉",14538,214,112.9,7711,6827,1395,9811,3332,"超高齡 (20–25%)"],["苗栗縣","西湖鄉",5907,144,130.7,3346,2561,290,3896,1721,"超高齡 (≥25%)"],["苗栗縣","造橋鄉",11588,239,113.7,6166,5422,860,7922,2806,"超高齡 (20–25%)"],["苗栗縣","三灣鄉",5702,105,122,3133,2569,471,3664,1567,"超高齡 (≥25%)"],["苗栗縣","獅潭鄉",3954,50,120.5,2161,1793,194,2497,1263,"超高齡 (≥25%)"],["苗栗縣","泰安鄉",5423,9,117.8,2933,2490,508,3902,1013,"高齡 (14–20%)"],["連江縣","南竿鄉",7634,721,129.5,4308,3326,832,5486,1316,"高齡 (14–20%)"],["連江縣","北竿鄉",2953,303,132.7,1684,1269,228,2215,510,"高齡 (14–20%)"],["連江縣","莒光鄉",1536,315,169.5,966,570,77,1154,305,"高齡 (14–20%)"],["連江縣","東引鄉",1512,330,169.5,951,561,160,1170,182,"高齡化 (7–14%)"],["金門縣","金城鎮",41159,1825,98.4,20411,20748,3514,29043,8602,"超高齡 (20–25%)"],["金門縣","金湖鎮",30535,726,99.4,15218,15317,2678,22219,5638,"高齡 (14–20%)"],["金門縣","金沙鎮",19938,367,96.8,9809,10129,1142,14296,4500,"超高齡 (20–25%)"],["金門縣","金寧鄉",35364,831,99.9,17669,17695,2796,27021,5547,"高齡 (14–20%)"],["金門縣","烈嶼鄉",12098,570,97.5,5971,6127,621,8762,2715,"超高齡 (20–25%)"],["金門縣","烏坵鄉",595,248,108,309,286,53,460,82,"高齡化 (7–14%)"],["雲林縣","斗六市",109207,1187,96.4,53608,55599,14164,75180,19863,"高齡 (14–20%)"],["雲林縣","斗南鎮",43374,896,101.9,21891,21483,4594,29528,9252,"超高齡 (20–25%)"],["雲林縣","虎尾鎮",71452,1043,100.1,35751,35701,9229,49239,12984,"高齡 (14–20%)"],["雲林縣","西螺鎮",44070,878,100.3,22069,22001,5431,29534,9105,"超高齡 (20–25%)"],["雲林縣","土庫鎮",27264,566,108.2,14171,13093,2934,18252,6078,"超高齡 (20–25%)"],["雲林縣","北港鎮",37220,892,104.7,19038,18182,4084,24757,8379,"超高齡 (20–25%)"],["雲林縣","古坑鄉",29320,176,108.3,15242,14078,2367,19773,7180,"超高齡 (20–25%)"],["雲林縣","大埤鄉",17594,396,112.5,9313,8281,1483,11951,4160,"超高齡 (20–25%)"],["雲林縣","莿桐鄉",27286,476,106.9,14100,13186,2768,18522,5996,"超高齡 (20–25%)"],["雲林縣","林內鄉",16414,314,109.7,8587,7827,1621,11061,3732,"超高齡 (20–25%)"],["雲林縣","二崙鄉",24266,398,114.6,12961,11305,1952,15997,6317,"超高齡 (≥25%)"],["雲林縣","崙背鄉",22329,390,112.3,11811,10518,2056,14680,5593,"超高齡 (≥25%)"],["雲林縣","麥寮鄉",48800,388,97.3,24064,24736,6659,34975,7166,"高齡 (14–20%)"],["雲林縣","東勢鄉",12960,278,124.2,7179,5781,891,8549,3520,"超高齡 (≥25%)"],["雲林縣","褒忠鄉",11529,323,115.1,6169,5360,957,7667,2905,"超高齡 (≥25%)"],["雲林縣","臺西鄉",20878,300,114.3,11135,9743,1537,14350,4991,"超高齡 (20–25%)"],["雲林縣","元長鄉",22586,312,120.7,12354,10232,1660,14461,6465,"超高齡 (≥25%)"],["雲林縣","四湖鄉",20322,218,120.5,11107,9215,1314,13749,5259,"超高齡 (≥25%)"],["雲林縣","口湖鄉",24085,243,114.1,12834,11251,1771,16637,5677,"超高齡 (20–25%)"],["雲林縣","水林鄉",21918,300,121.3,12015,9903,1488,14194,6236,"超高齡 (≥25%)"],["高雄市","鹽埕區",21942,13220,96.7,10786,11156,1539,14011,6392,"超高齡 (≥25%)"],["高雄市","鼓山區",140817,6351,90.4,66868,73949,19450,93887,27480,"高齡 (14–20%)"],["高雄市","左營區",197775,8718,89.6,93482,104293,24154,140078,33543,"高齡 (14–20%)"],["高雄市","楠梓區",195604,6886,94.6,95112,100492,27000,137140,31464,"高齡 (14–20%)"],["高雄市","三民區",329100,19338,91.2,156941,172159,36330,221710,71060,"超高齡 (20–25%)"],["高雄市","新興區",49354,19435,90.1,23398,25956,5290,30743,13321,"超高齡 (≥25%)"],["高雄市","前金區",27608,14016,87.3,12869,14739,1860,18112,7636,"超高齡 (≥25%)"],["高雄市","苓雅區",161503,19229,89.8,76396,85107,16873,103453,41177,"超高齡 (≥25%)"],["高雄市","前鎮區",177427,8343,94.5,86219,91208,16477,120971,39979,"超高齡 (20–25%)"],["高雄市","旗津區",25019,1719,104.5,12785,12234,1837,17754,5428,"超高齡 (20–25%)"],["高雄市","小港區",153179,2834,96.6,75256,77923,17140,107890,28149,"高齡 (14–20%)"],["高雄市","鳳山區",353431,12639,93.9,171151,182280,41893,243564,67974,"高齡 (14–20%)"],["高雄市","林園區",67447,1880,99.9,33714,33733,7079,47682,12686,"高齡 (14–20%)"],["高雄市","大寮區",112310,1598,102,56717,55593,10736,80168,21406,"高齡 (14–20%)"],["高雄市","大樹區",39988,591,103.4,20327,19661,3329,27736,8923,"超高齡 (20–25%)"],["高雄市","大社區",33791,1330,102,17066,16725,2890,24000,6901,"超高齡 (20–25%)"],["高雄市","仁武區",100067,2640,100.4,50125,49942,11278,73051,15738,"高齡 (14–20%)"],["高雄市","鳥松區",43758,1767,100,21879,21879,3444,29905,10409,"超高齡 (20–25%)"],["高雄市","岡山區",94750,1902,96.8,46615,48135,11382,64960,18408,"高齡 (14–20%)"],["高雄市","橋頭區",43320,1773,99.4,21595,21725,4528,30139,8653,"高齡 (14–20%)"],["高雄市","燕巢區",28405,415,109,14815,13590,2341,19684,6380,"超高齡 (20–25%)"],["高雄市","田寮區",6162,68,124.1,3412,2750,267,3841,2054,"超高齡 (≥25%)"],["高雄市","阿蓮區",26817,766,100.1,13414,13403,2706,18437,5674,"超高齡 (20–25%)"],["高雄市","路竹區",49123,968,102.4,24858,24265,5804,33021,10298,"超高齡 (20–25%)"],["高雄市","湖內區",29340,1346,103.5,14919,14421,2697,20899,5744,"高齡 (14–20%)"],["高雄市","茄萣區",28771,1683,103.4,14629,14142,2532,20068,6171,"超高齡 (20–25%)"],["高雄市","永安區",13529,504,98.2,6704,6825,1271,9693,2565,"高齡 (14–20%)"],["高雄市","彌陀區",17793,1205,103.3,9043,8750,1581,12505,3707,"超高齡 (20–25%)"],["高雄市","梓官區",34727,2925,104.8,17768,16959,2957,24748,7022,"超高齡 (20–25%)"],["高雄市","旗山區",33487,353,104.8,17136,16351,2980,21662,8845,"超高齡 (≥25%)"],["高雄市","美濃區",36237,305,111,19062,17175,2425,22499,11313,"超高齡 (≥25%)"],["高雄市","六龜區",11329,63,116.7,6101,5228,751,7446,3132,"超高齡 (≥25%)"],["高雄市","甲仙區",5301,43,110.9,2788,2513,348,3454,1499,"超高齡 (≥25%)"],["高雄市","杉林區",10595,102,120.3,5785,4810,686,6887,3022,"超高齡 (≥25%)"],["高雄市","內門區",12609,133,116.6,6789,5820,735,8403,3471,"超高齡 (≥25%)"],["高雄市","茂林區",1838,8,96.8,904,934,234,1390,214,"高齡化 (7–14%)"],["高雄市","桃源區",4137,4,108.4,2152,1985,564,3077,496,"高齡化 (7–14%)"],["高雄市","那瑪夏區",3110,18,105,1593,1517,544,2219,347,"高齡化 (7–14%)"]]}
|