@makechart/worldmap 0.0.1 → 0.0.2

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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # Change Logs
2
2
 
3
+ ## v0.0.2
4
+
5
+ - explicitly extend `@makechart/base` `d3/index.html`, since `pdmap-world` still needs d3
6
+ - add test cases ( `test/index.ls`, run with `npm test` via `@makechart/viewer` )
7
+
8
+
3
9
  ## v0.0.1
4
10
 
5
11
  init release
package/index.html CHANGED
@@ -1 +1 @@
1
- <div><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">123</div></div><div data-type="render"></div></div></div><style type="text/css">.pdl-layout>div[data-type=layout]{display:grid;grid-template-columns:1fr fit-content(5em)}</style><script type="@plotdb/block">var mod;module.exports={pkg:{name:"worldmap",version:"0.0.1",extend:{name:"@makechart/base"},dependencies:[{url:"https://d3js.org/d3-geo.v2.min.js",async:false},{url:"https://d3js.org/topojson.v2.min.js",async:false},{url:"/assets/lib/@plotdb/pdmap-world/main/index.js"}]},init:function(t){var e,n,r;e=t.root,n=t.context,r=t.pubsub;return r.fire("init",{mod:mod({context:n})})}};mod=function(t){var e,n,u,i,l,r;e=t.context;n=e.chart,u=e.d3,i=e.ldcolor,l=e.pdmapWorld,r=e.topojson;return{sample:function(){return{raw:l.meta.alpha2.map(function(t){return{country:t,val:Math.random()}}),binding:{color:{key:"val"},name:{key:"country"}}}},config:{},dimension:{name:{type:"N",name:"國家"},color:{type:"R",name:"顏色"}},init:function(){var e,s=this;this.g=this.layout.getGroup("view");this.obj=new l({root:this.g});this.scale=e={color:u.interpolateTurbo};this.legend=new n.utils.legend({root:this.root,name:"legend",layout:this.layout,shape:function(t){return u.select(this).attr("fill",e.color(t.key))}});this.tip=new n.utils.tip({root:this.root,accessor:function(t){var e,n,r,i,o,a;e=t.evt;if(!(e.target&&(n=u.select(e.target).datum()))){return null}r=function(){var t,e=[];for(i in t=l.meta.zhalpha2){o=t[i];e.push([i,o])}return e}().filter(function(t){return t[1].toLowerCase()===n.properties.alpha2})[0];a=r?r[0]:n.properties.shortname||n.data.name;o=isNaN(n.data.color)?"-":n.data.color.toFixed(2)+""+(s.binding.color.unit||"");return{name:a,value:o}},range:function(){return s.layout.getNode("view").getBoundingClientRect()}});return this.obj.init().then(function(){return s.obj.fit()})},destroy:function(){return this.tip.destroy()},parse:function(){var t,e=this;t=u.select(this.g).selectAll("path").data();t.map(function(t){t.data=null;t.properties.value=0;return t.properties.data={}});this.data.map(function(t){return{c:e.obj.findCountry(t.name),v:t}}).filter(function(t){return t.c}).map(function(t){var e;return e=t.c,e.value=t.v.color,e.data=t.v,e});t.map(function(t){return t.data=t.properties.data||{}});return this.extent={c:u.extent(t,function(t){return t.properties.value})}},resize:function(){var t,e,n,r=this;this.tip.toggle(((t=this.cfg).tip||(t.tip={})).enabled!=null?this.cfg.tip.enabled:true);this.obj.fit(this.layout.getBox("view"));e=this.cfg.palette?this.cfg.palette.colors:["#f00","#999","#00f"];n=e.length;this.ticks=u.quantize(function(t){return(1-t)*(r.extent.c[1]-r.extent.c[0])+r.extent.c[0]},n).map(function(t){var e;return{key:t,text:u.format(r.cfg.legendFormat||".2f")(t)+((e=r.binding.color.unit)?e:"")}});this.ticks.sort(function(t,e){return t.key-e.key});if(this.cfg.palette){this.scale.color=u.scaleLinear().domain(this.ticks.map(function(t){return t.key})).range(e.map(function(t){return i.web(t.value||t)}))}return this.legend.data(this.ticks)},render:function(){var n=this;this.legend.render();return u.select(this.g).selectAll("path").transition().duration(350).attr("fill",function(t,e){return n.scale.color(t.properties.value)}).attr("fill-opacity",function(t,e){if(n.cfg.dimEmpty){if(t.properties.value){return 1}else{return.2}}else{return 1}})}}};</script></div>
1
+ <div><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">123</div></div><div data-type="render"></div></div></div><style type="text/css">.pdl-layout>div[data-type=layout]{display:grid;grid-template-columns:1fr fit-content(5em)}</style><script type="@plotdb/block">var mod;module.exports={pkg:{name:"worldmap",version:"0.0.1",extend:{name:"@makechart/base",path:"d3/index.html"},dependencies:[{url:"https://d3js.org/d3-geo.v2.min.js",async:false},{url:"https://d3js.org/topojson.v2.min.js",async:false},{url:"/assets/lib/@plotdb/pdmap-world/main/index.js"}]},init:function(t){var e,n,r;e=t.root,n=t.context,r=t.pubsub;return r.fire("init",{mod:mod({context:n})})}};mod=function(t){var e,n,u,i,l,r;e=t.context;n=e.chart,u=e.d3,i=e.ldcolor,l=e.pdmapWorld,r=e.topojson;return{sample:function(){return{raw:l.meta.alpha2.map(function(t){return{country:t,val:Math.random()}}),binding:{color:{key:"val"},name:{key:"country"}}}},config:{},dimension:{name:{type:"N",name:"國家"},color:{type:"R",name:"顏色"}},init:function(){var e,s=this;this.g=this.layout.getGroup("view");this.obj=new l({root:this.g});this.scale=e={color:u.interpolateTurbo};this.legend=new n.utils.legend({root:this.root,name:"legend",layout:this.layout,shape:function(t){return u.select(this).attr("fill",e.color(t.key))}});this.tip=new n.utils.tip({root:this.root,accessor:function(t){var e,n,r,i,o,a;e=t.evt;if(!(e.target&&(n=u.select(e.target).datum()))){return null}r=function(){var t,e=[];for(i in t=l.meta.zhalpha2){o=t[i];e.push([i,o])}return e}().filter(function(t){return t[1].toLowerCase()===n.properties.alpha2})[0];a=r?r[0]:n.properties.shortname||n.data.name;o=isNaN(n.data.color)?"-":n.data.color.toFixed(2)+""+(s.binding.color.unit||"");return{name:a,value:o}},range:function(){return s.layout.getNode("view").getBoundingClientRect()}});return this.obj.init().then(function(){return s.obj.fit()})},destroy:function(){return this.tip.destroy()},parse:function(){var t,e=this;t=u.select(this.g).selectAll("path").data();t.map(function(t){t.data=null;t.properties.value=0;return t.properties.data={}});this.data.map(function(t){return{c:e.obj.findCountry(t.name),v:t}}).filter(function(t){return t.c}).map(function(t){var e;return e=t.c,e.value=t.v.color,e.data=t.v,e});t.map(function(t){return t.data=t.properties.data||{}});return this.extent={c:u.extent(t,function(t){return t.properties.value})}},resize:function(){var t,e,n,r=this;this.tip.toggle(((t=this.cfg).tip||(t.tip={})).enabled!=null?this.cfg.tip.enabled:true);this.obj.fit(this.layout.getBox("view"));e=this.cfg.palette?this.cfg.palette.colors:["#f00","#999","#00f"];n=e.length;this.ticks=u.quantize(function(t){return(1-t)*(r.extent.c[1]-r.extent.c[0])+r.extent.c[0]},n).map(function(t){var e;return{key:t,text:u.format(r.cfg.legendFormat||".2f")(t)+((e=r.binding.color.unit)?e:"")}});this.ticks.sort(function(t,e){return t.key-e.key});if(this.cfg.palette){this.scale.color=u.scaleLinear().domain(this.ticks.map(function(t){return t.key})).range(e.map(function(t){return i.web(t.value||t)}))}return this.legend.data(this.ticks)},render:function(){var n=this;this.legend.render();return u.select(this.g).selectAll("path").transition().duration(350).attr("fill",function(t,e){return n.scale.color(t.properties.value)}).attr("fill-opacity",function(t,e){if(n.cfg.dimEmpty){if(t.properties.value){return 1}else{return.2}}else{return 1}})}}};</script></div>
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"@makechart/worldmap","version":"0.0.1","description":"","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"keywords":[],"author":"zbryikt","license":"MIT","dependencies":{"@plotdb/srcbuild":"^0.0.69","fedep":"1.6.0","livescript":"^1.6.0"}}
1
+ {"name":"@makechart/worldmap","version":"0.0.2","description":"","scripts":{"test":"mctest","test:serve":"mctest serve -o","test:dev":"mctest -l \"@makechart/base:../base;@plotdb/chart:../../../plotdb/projects/chart;@plotdb/dash:../../../plotdb/projects/dash\"","test:dev:serve":"mctest serve -o -l \"@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.3"}}