Socket
Socket
Sign inDemoInstall

d3-geo-scale-bar

Package Overview
Dependencies
1
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.5.1 to 0.5.2

.DS_Store

10

build/d3-geo-scale-bar.js

@@ -1,2 +0,2 @@

// https://github.com/HarryStevens/d3-geo-scale-bar Version 0.5.1. Copyright 2020 Harry Stevens.
// https://github.com/HarryStevens/d3-geo-scale-bar Version 0.5.2. Copyright 2020 Harry Stevens.
(function (global, factory) {

@@ -260,3 +260,3 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :

// If a distance has not been explicitly set, set it
distance = distance || inferDistance(extent, radius); // If a label has not been explicitly set, set it
var barDistance = distance || inferDistance(extent, radius); // If a label has not been explicitly set, set it

@@ -270,7 +270,7 @@ labelText = labelText === null ? null : labelText || capitalizeFirstLetter(units); // The position, width, and ticks of the scale bar

start = projection.invert([x, y]),
barWidth = distance / (geoDistance(start, projection.invert([x + 1, y])) * radius),
max = distance / zoomFactor,
barWidth = barDistance / (geoDistance(start, projection.invert([x + 1, y])) * radius),
max = barDistance / zoomFactor,
values = tickValues === null ? [] : tickValues ? tickValues : [0, max / 4, max / 2, max],
scale = function scale(dist) {
return dist * barWidth / (distance / zoomFactor);
return dist * barWidth / (barDistance / zoomFactor);
},

@@ -277,0 +277,0 @@ selection = context.selection ? context.selection() : context,

@@ -1,1 +0,1 @@

!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n(t.d3=t.d3||{})}(this,function(t){"use strict";function n(){this.reset()}function e(t,n,e){var r=t.s=n+e,o=r-n,i=r-o;t.t=n-i+(e-o)}function r(t,n){t&&v.hasOwnProperty(t.type)&&v[t.type](t,n)}function o(t,n,e){var r,o=-1,i=t.length-e;for(n.lineStart();++o<i;)r=t[o],n.point(r[0],r[1],r[2]);n.lineEnd()}function i(t,n){var e=-1,r=t.length;for(n.polygonStart();++e<r;)o(t[e],n,1);n.polygonEnd()}function a(t,n){t&&M.hasOwnProperty(t.type)?M[t.type](t,n):r(t,n)}function c(){x.point=l,x.lineEnd=u}function u(){x.point=x.lineEnd=function(t){}}function l(t,n){t*=Math.PI/180,n*=Math.PI/180,p=t,g=Math.sin(n),y=Math.cos(n),x.point=f}function f(t,n){t*=Math.PI/180,n*=Math.PI/180;var e=Math.sin(n),r=Math.cos(n),o=Math.abs(t-p),i=Math.cos(o),a=Math.sin(o),c=r*a,u=y*e-g*r*i,l=g*e+y*r*i;k.add(Math.atan2(Math.sqrt(c*c+u*u),l)),p=t,g=e,y=r}function s(t){return k.reset(),a(t,x),+k}function h(t,n){return P[0]=t,P[1]=n,s(S)}function d(){function t(t,e){return Math.pow(10,n(h(o.invert(t[0]),o.invert([t[1][0],t[0][1]]))*e)-1)}function n(t){return Math.floor(t).toString().length}function e(t){return t.charAt(0).toUpperCase()+t.slice(1)}function r(n){i=i||t(u,d),c=null===c?null:c||e(s);var r=u[1][0]-u[0][0],M=u[1][1]-u[0][1],v=u[0][0]+r*l,k=u[0][1]+M*f,x=o.invert([v,k]),P=i/(h(x,o.invert([v+1,k]))*d),S=i/m,C=null===a?[]:a||[0,S/4,S/2,S],b=function(t){return t*P/(i/m)},w=n.selection?n.selection():n,E=w.selectAll(".label").data([c]),L=w.selectAll(".domain").data([null]),z=w.selectAll(".tick").data(C,b).order(),A=z.exit(),O=z.enter().append("g").attr("class","tick"),j=z.select("line"),F=z.select("text"),I=z.select("rect");w.attr("font-family","sans-serif").attr("transform","translate(".concat([v,k],")")),L=L.merge(L.enter().insert("path",".tick").attr("class","domain").attr("fill","none").attr("stroke","currentColor")),z=z.merge(O),j=j.merge(O.append("line").attr("stroke","currentColor").attr("y2",g)),F=F.merge(O.append("text").attr("fill","currentColor").attr("y",g+2).attr("font-size",10).attr("text-anchor","middle").attr("dy","0.71em")),I=I.merge(O.append("rect").attr("fill",function(t,n){return n%2==0?"currentColor":"#fff"}).attr("stroke","currentColor").attr("stroke-width",.5).attr("width",function(t,n,e){return n===e.length-1?0:b(C[n+1]-t)}).attr("height",g)),n!==w&&(z=z.transition(n),L=L.transition(n),I=I.transition(n),A=A.transition(n).attr("opacity",1e-6).attr("transform",function(t){return"translate(".concat(b(t),")")}),O.attr("opacity",1e-6).attr("transform",function(t){return"translate(".concat(b(t),")")})),A.remove(),L.attr("d","M".concat(b(0),",").concat(g," L").concat(b(0),",0 L").concat(b(S),",0 L").concat(b(S),",").concat(g)),z.attr("transform",function(t){return"translate(".concat(b(t),")")}).attr("opacity",1),j.attr("y2",g),F.attr("y",g+2).text(p),I.attr("fill",function(t,n){return n%2==0?"currentColor":"#fff"}).attr("width",function(t,n,e){return n===e.length-1?0:b(C[n+1]-t)}).attr("height",g),null===E?E.remove():E.enter().append("text").attr("class","label").attr("fill","currentColor").attr("font-size",12).attr("dy","-0.32em").merge(E).attr("x","start"===y?0:b("middle"===y?S/2:S)).attr("text-anchor",y).text(function(t){return t})}var o,i,a,c,u=null,l=0,f=0,s="kilometers",d=6371,p=function(t){return Math.round(t)},g=4,y="start",m=1,M={miles:{radius:3959},kilometers:{radius:6371}};return r.extent=function(t){return arguments.length?(u=t,r):u},r.size=function(t){return arguments.length?(u=[[0,0],t],r):u[1]},r.projection=function(t){return arguments.length?(o=t,r):o},r.units=function(t){return arguments.length?(s=t,Object.keys(M).includes(t)&&(d=M[t].radius),r):s},r.left=function(t){return arguments.length?(l=+t>1?1:+t<0?0:+t,r):l},r.top=function(t){return arguments.length?(f=+t>1?1:+t<0?0:+t,r):f},r.distance=function(t){return arguments.length?(i=+t,r):i},r.radius=function(t){return arguments.length?(d=+t,r):d},r.tickValues=function(t){return arguments.length?(a=t,r):a},r.tickFormat=function(t){return arguments.length?(p=t,r):p},r.tickSize=function(t){return arguments.length?(g=+t,r):g},r.label=function(t){return arguments.length?(c=t,r):c},r.labelAnchor=function(t){return arguments.length?(y=t,r):y},r.zoomFactor=function(t){return arguments.length?(m=+t,r):m},r}n.prototype={constructor:n,reset:function(){this.s=this.t=0},add:function(t){e(m,t,this.t),e(this,m.s,this.s),this.s?this.t+=m.t:this.s=m.t},valueOf:function(){return this.s}};var p,g,y,m=new n,M={Feature:function(t,n){r(t.geometry,n)},FeatureCollection:function(t,n){for(var e=t.features,o=-1,i=e.length;++o<i;)r(e[o].geometry,n)}},v={Sphere:function(t,n){n.sphere()},Point:function(t,n){t=t.coordinates,n.point(t[0],t[1],t[2])},MultiPoint:function(t,n){for(var e=t.coordinates,r=-1,o=e.length;++r<o;)t=e[r],n.point(t[0],t[1],t[2])},LineString:function(t,n){o(t.coordinates,n,0)},MultiLineString:function(t,n){for(var e=t.coordinates,r=-1,i=e.length;++r<i;)o(e[r],n,0)},Polygon:function(t,n){i(t.coordinates,n)},MultiPolygon:function(t,n){for(var e=t.coordinates,r=-1,o=e.length;++r<o;)i(e[r],n)},GeometryCollection:function(t,n){for(var e=t.geometries,o=-1,i=e.length;++o<i;)r(e[o],n)}},k=function(){return new n}(),x={sphere:function(t){},point:function(t){},lineStart:c,lineEnd:function(t){},polygonStart:function(t){},polygonEnd:function(t){}},P=[null,null],S={type:"LineString",coordinates:P};t.geoScaleBar=d,Object.defineProperty(t,"__esModule",{value:!0})});
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n(t.d3=t.d3||{})}(this,function(t){"use strict";function n(){this.reset()}function e(t,n,e){var r=t.s=n+e,o=r-n,i=r-o;t.t=n-i+(e-o)}function r(t,n){t&&M.hasOwnProperty(t.type)&&M[t.type](t,n)}function o(t,n,e){var r,o=-1,i=t.length-e;for(n.lineStart();++o<i;)r=t[o],n.point(r[0],r[1],r[2]);n.lineEnd()}function i(t,n){var e=-1,r=t.length;for(n.polygonStart();++e<r;)o(t[e],n,1);n.polygonEnd()}function a(t,n){t&&v.hasOwnProperty(t.type)?v[t.type](t,n):r(t,n)}function c(){x.point=l,x.lineEnd=u}function u(){x.point=x.lineEnd=function(t){}}function l(t,n){t*=Math.PI/180,n*=Math.PI/180,p=t,g=Math.sin(n),y=Math.cos(n),x.point=f}function f(t,n){t*=Math.PI/180,n*=Math.PI/180;var e=Math.sin(n),r=Math.cos(n),o=Math.abs(t-p),i=Math.cos(o),a=Math.sin(o),c=r*a,u=y*e-g*r*i,l=g*e+y*r*i;k.add(Math.atan2(Math.sqrt(c*c+u*u),l)),p=t,g=e,y=r}function s(t){return k.reset(),a(t,x),+k}function h(t,n){return P[0]=t,P[1]=n,s(S)}function d(){function t(t,e){return Math.pow(10,n(h(o.invert(t[0]),o.invert([t[1][0],t[0][1]]))*e)-1)}function n(t){return Math.floor(t).toString().length}function e(t){return t.charAt(0).toUpperCase()+t.slice(1)}function r(n){var r=i||t(u,d);c=null===c?null:c||e(s);var v=u[1][0]-u[0][0],M=u[1][1]-u[0][1],k=u[0][0]+v*l,x=u[0][1]+M*f,P=o.invert([k,x]),S=r/(h(P,o.invert([k+1,x]))*d),C=r/m,b=null===a?[]:a||[0,C/4,C/2,C],w=function(t){return t*S/(r/m)},E=n.selection?n.selection():n,L=E.selectAll(".label").data([c]),z=E.selectAll(".domain").data([null]),A=E.selectAll(".tick").data(b,w).order(),O=A.exit(),j=A.enter().append("g").attr("class","tick"),F=A.select("line"),I=A.select("text"),_=A.select("rect");E.attr("font-family","sans-serif").attr("transform","translate(".concat([k,x],")")),z=z.merge(z.enter().insert("path",".tick").attr("class","domain").attr("fill","none").attr("stroke","currentColor")),A=A.merge(j),F=F.merge(j.append("line").attr("stroke","currentColor").attr("y2",g)),I=I.merge(j.append("text").attr("fill","currentColor").attr("y",g+2).attr("font-size",10).attr("text-anchor","middle").attr("dy","0.71em")),_=_.merge(j.append("rect").attr("fill",function(t,n){return n%2==0?"currentColor":"#fff"}).attr("stroke","currentColor").attr("stroke-width",.5).attr("width",function(t,n,e){return n===e.length-1?0:w(b[n+1]-t)}).attr("height",g)),n!==E&&(A=A.transition(n),z=z.transition(n),_=_.transition(n),O=O.transition(n).attr("opacity",1e-6).attr("transform",function(t){return"translate(".concat(w(t),")")}),j.attr("opacity",1e-6).attr("transform",function(t){return"translate(".concat(w(t),")")})),O.remove(),z.attr("d","M".concat(w(0),",").concat(g," L").concat(w(0),",0 L").concat(w(C),",0 L").concat(w(C),",").concat(g)),A.attr("transform",function(t){return"translate(".concat(w(t),")")}).attr("opacity",1),F.attr("y2",g),I.attr("y",g+2).text(p),_.attr("fill",function(t,n){return n%2==0?"currentColor":"#fff"}).attr("width",function(t,n,e){return n===e.length-1?0:w(b[n+1]-t)}).attr("height",g),null===L?L.remove():L.enter().append("text").attr("class","label").attr("fill","currentColor").attr("font-size",12).attr("dy","-0.32em").merge(L).attr("x","start"===y?0:w("middle"===y?C/2:C)).attr("text-anchor",y).text(function(t){return t})}var o,i,a,c,u=null,l=0,f=0,s="kilometers",d=6371,p=function(t){return Math.round(t)},g=4,y="start",m=1,v={miles:{radius:3959},kilometers:{radius:6371}};return r.extent=function(t){return arguments.length?(u=t,r):u},r.size=function(t){return arguments.length?(u=[[0,0],t],r):u[1]},r.projection=function(t){return arguments.length?(o=t,r):o},r.units=function(t){return arguments.length?(s=t,Object.keys(v).includes(t)&&(d=v[t].radius),r):s},r.left=function(t){return arguments.length?(l=+t>1?1:+t<0?0:+t,r):l},r.top=function(t){return arguments.length?(f=+t>1?1:+t<0?0:+t,r):f},r.distance=function(t){return arguments.length?(i=+t,r):i},r.radius=function(t){return arguments.length?(d=+t,r):d},r.tickValues=function(t){return arguments.length?(a=t,r):a},r.tickFormat=function(t){return arguments.length?(p=t,r):p},r.tickSize=function(t){return arguments.length?(g=+t,r):g},r.label=function(t){return arguments.length?(c=t,r):c},r.labelAnchor=function(t){return arguments.length?(y=t,r):y},r.zoomFactor=function(t){return arguments.length?(m=+t,r):m},r}n.prototype={constructor:n,reset:function(){this.s=this.t=0},add:function(t){e(m,t,this.t),e(this,m.s,this.s),this.s?this.t+=m.t:this.s=m.t},valueOf:function(){return this.s}};var p,g,y,m=new n,v={Feature:function(t,n){r(t.geometry,n)},FeatureCollection:function(t,n){for(var e=t.features,o=-1,i=e.length;++o<i;)r(e[o].geometry,n)}},M={Sphere:function(t,n){n.sphere()},Point:function(t,n){t=t.coordinates,n.point(t[0],t[1],t[2])},MultiPoint:function(t,n){for(var e=t.coordinates,r=-1,o=e.length;++r<o;)t=e[r],n.point(t[0],t[1],t[2])},LineString:function(t,n){o(t.coordinates,n,0)},MultiLineString:function(t,n){for(var e=t.coordinates,r=-1,i=e.length;++r<i;)o(e[r],n,0)},Polygon:function(t,n){i(t.coordinates,n)},MultiPolygon:function(t,n){for(var e=t.coordinates,r=-1,o=e.length;++r<o;)i(e[r],n)},GeometryCollection:function(t,n){for(var e=t.geometries,o=-1,i=e.length;++o<i;)r(e[o],n)}},k=function(){return new n}(),x={sphere:function(t){},point:function(t){},lineStart:c,lineEnd:function(t){},polygonStart:function(t){},polygonEnd:function(t){}},P=[null,null],S={type:"LineString",coordinates:P};t.geoScaleBar=d,Object.defineProperty(t,"__esModule",{value:!0})});
{
"name": "d3-geo-scale-bar",
"version": "0.5.1",
"version": "0.5.2",
"description": "Displays automatic scale bars for projected geospatial data.",

@@ -5,0 +5,0 @@ "keywords": [

@@ -14,3 +14,3 @@ # d3-geo-scale-bar

```html
<script src="https://unpkg.com/d3-geo-scale-bar@0.5.1/build/d3-geo-scale-bar.min.js"></script>
<script src="https://unpkg.com/d3-geo-scale-bar@0.5.2/build/d3-geo-scale-bar.min.js"></script>
<script>

@@ -28,3 +28,4 @@

.attr("height", height)
.append("g").call(scaleBar);
.append("g")
.call(scaleBar);

@@ -31,0 +32,0 @@ </script>

@@ -41,3 +41,3 @@ import { default as geoDistance } from "./geo/distance";

// If a distance has not been explicitly set, set it
distance = distance || inferDistance(extent, radius);
const barDistance = distance || inferDistance(extent, radius);

@@ -53,6 +53,6 @@ // If a label has not been explicitly set, set it

start = projection.invert([x, y]),
barWidth = distance / (geoDistance(start, projection.invert([x + 1, y])) * radius),
max = distance / zoomFactor,
barWidth = barDistance / (geoDistance(start, projection.invert([x + 1, y])) * radius),
max = barDistance / zoomFactor,
values = tickValues === null ? [] : tickValues ? tickValues : [0, max / 4, max / 2, max],
scale = dist => dist * barWidth / (distance / zoomFactor),
scale = dist => dist * barWidth / (barDistance / zoomFactor),
selection = context.selection ? context.selection() : context,

@@ -59,0 +59,0 @@ label = selection.selectAll(".label").data([labelText]),

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc