@makechart/delaunay 0.0.1
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 +5 -0
- package/LICENSE +21 -0
- package/index.html +1 -0
- package/package.json +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 zbryikt
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/index.html
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<div><div plug="layout"><div class="pdl-layout"><div data-type="layout"><div class="pdl-cell" data-name="axis-left"></div><div class="pdl-cell" data-name="view"></div><div class="pdl-cell"></div><div class="pdl-cell" data-name="axis-bottom"></div><div class="pdl-cell" data-name="legend"></div></div><div data-type="render"></div></div></div><style type="text/css">.pdl-layout>div[data-type=layout]{display:grid;grid-template-columns:2em 1fr;grid-template-rows:1fr 1em 3em;padding:20px 20px 0 20px}.pdl-layout>div[data-type=layout] .pdl-cell[data-name=legend]{grid-column:1/span 2;grid-row:3}</style><script type="@plotdb/block">var mod;module.exports={pkg:{name:"scatter",version:"0.0.1",extend:{name:"@makechart/base"},dependencies:[{url:"https://cdn.jsdelivr.net/npm/d3-delaunay@6/dist/d3-delaunay.min.js"}]},init:function(t){var e,n,i;e=t.root,n=t.context,i=t.pubsub;return i.fire("init",{mod:mod({context:n})})}};mod=function(t){var e,x,n,i;e=t.context;x=e.d3,n=e.chart;i=["The Glenn Miller Story","The Fifth Element","Forrest Gump","Finding Nemo","The Fly","First Blood","You Can't Take It with You","Man of the Year","From Hell","The Easy Rider","The English Patient","The Extra-Terrestial","Edward Scissorhands","Empire of the Sun","Encounters of the Third Kind","Elizabeth: The Golden Age"];return{sample:function(){return{raw:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100].map(function(t){var e;e={x:Math.random(),y:Math.random(),name:i[Math.floor(Math.random()*i.length)]};return e}),binding:{x:{key:"x"},y:{key:"y"},name:{key:"name"}}}},config:{},dimension:{x:{type:"R",name:"x axis"},y:{type:"R",name:"y axis"},radius:{type:"R",name:"radius"},category:{type:"CN",name:"category"},name:{type:"N",name:"name"}},init:function(){var t,e=this;this.tint=t=new n.utils.tint;["view","yaxis","xaxis"].map(function(t){return(e.g||(e.g={}))[t]=x.select(e.layout.getGroup(t))});return this.path=x.select(this.svg).append("path")},parse:function(){},resize:function(){var t,e,n,i,u=this;t=[this.box.width,this.box.height],e=t[0],n=t[1];this.extent={x:x.extent(this.data.map(function(t){return t.x})),y:x.extent(this.data.map(function(t){return t.y}))};i=this.layout.getBox("view");this.scale={x:x.scaleLinear().domain(this.extent.x).range([0,i.width]),y:x.scaleLinear().domain(this.extent.y).range([0,i.height])};this.pts=this.data.map(function(t){return[u.scale.x(t.x),u.scale.y(t.y)]});this.delaunay=x.Delaunay.from(this.pts);this.voronoi=this.delaunay.voronoi([0,0,i.width,i.height]);return this.cells=this.pts.map(function(t,e){var n,i,a,r,h,s,o,d,l;n=t[0],i=t[1];a=u.voronoi.cellPolygon(e);h=r=x.polygonCentroid(a),s=h[0],o=h[1];d=-x.polygonArea(a);l=(Math.round(Math.atan2(o-i,s-n)/Math.PI*2)+4)%4;return{point:t,polygon:a,centroid:r,area:d,angle:l}})},render:function(){var n,t,e;n=this.scale;t=this.g.view.selectAll("circle.data").data(this.data);t.exit().remove();t.enter().append("circle").attr("class","data").attr("cx",function(t,e){return n.x(t.x)}).attr("cy",function(t,e){return n.y(t.y)}).attr("r",3).attr("fill","#000");e=this.g.view.selectAll("text").data(this.data);e.exit().remove();e.enter().append("text").text(function(t,e){return t.name}).attr("x",function(t,e){if(t.nb){return t.nb.x}else{return n.x(t.x)}}).attr("y",function(t,e){if(t.nb){return t.nb.y}else{return n.y(t.y)}}).attr("text-anchor","middle").attr("dominant-baseline","middle");this.g.view.selectAll("text").data(this.data).attr("x",function(t,e){if(t.nb){return t.nb.x}else{return n.x(t.x)}}).attr("y",function(t,e){if(t.nb){return t.nb.y}else{return n.y(t.y)-20}}).attr("opacity",function(t,e){if(t.nb){if(t.nb.show){return 1}else{return 0}}else{return 1}});return this.path.attr("d",this.voronoi.render()).attr("stroke","#000").attr("transform",this.g.view.node().getAttribute("transform"))},tick:function(){var t,e,n,i,a,r,h,s,o,d,l,u,x,y;t=this.scale;this.g.view.selectAll("text").each(function(t,e){return t.box=this.getBoundingClientRect()});e=this.layout.getBox("view");for(n=0,i=this.data.length;n<i;++n){a=n;r=this.data[a].box;if(!this.data[a].nb){this.data[a].nb={x:t.x(this.data[a].x),y:t.y(this.data[a].y)-20}}h=this.data[a].nb;h.width=r.width;h.height=r.height;h.show=true}for(n=20;n<200;n+=20){s=n;for(o=0,i=this.data.length;o<i;++o){a=o;for(d=0;d<a;++d){l=d;h=[this.data[a].nb,this.data[l].nb],u=h[0],x=h[1];if((u.x>=x.x&&u.x<=x.x+x.width||u.x+u.width>=x.x&&u.x+u.width<=x.x+x.width)&&(u.y>=x.y&&u.y<=x.y+x.height||u.y+u.height>=x.y&&u.y+u.height<=x.y+x.height)){r=Math.random()*Math.PI*2;y=this.data[a];h=y.nb;h.x=t.x(y.x)+Math.cos(r)*s;h.y=t.y(y.y)+Math.sin(r)*s}}}}for(n=0,i=this.data.length;n<i;++n){a=n;for(o=0;o<a;++o){l=o;h=[this.data[a].nb,this.data[l].nb],u=h[0],x=h[1];if((u.x>=x.x&&u.x<=x.x+x.width||u.x+u.width>=x.x&&u.x+u.width<=x.x+x.width)&&(u.y>=x.y&&u.y<=x.y+x.height||u.y+u.height>=x.y&&u.y+u.height<=x.y+x.height)){this.data[a].nb.show=false}}}return this.render()}}};</script></div>
|
package/package.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"name":"@makechart/delaunay","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"}}
|