Socket
Socket
Sign inDemoInstall

d3-geo-scale-bar

Package Overview
Dependencies
0
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.1.1 to 1.1.2

4

build/d3-geo-scale-bar.js

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

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

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

tickFormat = function tickFormat(d) {
return Math.round(d);
return +d.toFixed(2);
},

@@ -242,0 +242,0 @@ tickPadding = 2,

@@ -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&&x.hasOwnProperty(t.type)&&x[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&&S.hasOwnProperty(t.type)?S[t.type](t,n):r(t,n)}function c(){P.point=l,P.lineEnd=u}function u(){P.point=P.lineEnd=function(t){}}function l(t,n){t*=Math.PI/180,n*=Math.PI/180,m=t,y=Math.sin(n),v=Math.cos(n),P.point=s}function s(t,n){t*=Math.PI/180,n*=Math.PI/180;var e=Math.sin(n),r=Math.cos(n),o=Math.abs(t-m),i=Math.cos(o),a=Math.sin(o),c=r*a,u=v*e-y*r*i,l=y*e+v*r*i;k.add(Math.atan2(Math.sqrt(c*c+u*u),l)),m=t,y=e,v=r}function f(t){return k.reset(),a(t,P),+k}function h(t,n){return C[0]=t,C[1]=n,f(b)}function d(){return 1}function g(){function t(t){o=null===o?null:o||s.charAt(0).toUpperCase()+s.slice(1);var d=i[1][0]-i[0][0],M=i[1][1]-i[0][1],S=i[0][0]+d*a,x=i[0][1]+M*c,k=n.invert([S,x]),P=0,C=0;if(e)P=e,C=P/(h(k,n.invert([S+1,x]))*l);else for(var b=.01,w=60/(v?1:y),z=0,E=[1,2,4,5];C<w&&z<100;){for(var L=0,A=E.length;L<A&&(P=b*E[L],!((C=P/(h(k,n.invert([S+1,x]))*l))>=w));L++);b*=10,z++}var F=P/(v?y:1),I=null===r?[]:r||[0,F/4,F/2,F],O=function(t){return t*C/(P/y)},j=t.selection?t.selection():t,B=j.selectAll(".label").data([o]),_=j.selectAll(".domain").data([null]),q=j.selectAll(".tick").data(I,O).order(),G=q.exit(),K=q.enter().append("g").attr("class","tick"),T=q.select("line"),U=q.select("text"),V=q.select("rect");j.attr("font-family","sans-serif").attr("transform","translate(".concat([S,x],")")),_=_.merge(_.enter().insert("path",".tick").attr("class","domain").attr("fill","none").attr("stroke","currentColor")),q=q.merge(K),T=T.merge(K.append("line").attr("stroke","currentColor").attr("y2",p*u)),U=U.merge(K.append("text").attr("fill","currentColor").attr("y",p*u+g*u).attr("font-size",10).attr("text-anchor","middle").attr("dy","".concat(1===u?.71:0,"em"))),V=V.merge(K.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:O(I[n+1]-t)}).attr("y",1===u?0:-p).attr("height",p)),t!==j&&(q=q.transition(t),_=_.transition(t),V=V.transition(t),G=G.transition(t).attr("opacity",1e-6).attr("transform",function(t){return"translate(".concat(O(t),")")}),K.attr("opacity",1e-6).attr("transform",function(t){return"translate(".concat(O(t),")")})),G.remove(),_.attr("d","M".concat(O(0),",").concat(p*u," L").concat(O(0),",0 L").concat(O(F),",0 L").concat(O(F),",").concat(p*u)),q.attr("transform",function(t){return"translate(".concat(O(t),")")}).attr("opacity",1),T.attr("y2",p*u),U.attr("y",p*u+g*u).text(f),V.attr("fill",function(t,n){return n%2==0?"currentColor":"#fff"}).attr("width",function(t,n,e){return n===e.length-1?0:O(I[n+1]-t)}).attr("y",1===u?0:-p).attr("height",p),null===B?B.remove():B.enter().append("text").attr("class","label").attr("fill","currentColor").attr("font-size",12).attr("dy","-0.32em").merge(B).attr("x","start"===m?0:O("middle"===m?F/2:F)).attr("y",1===u?0:"1.3em").attr("text-anchor",m).text(function(t){return t})}var n,e,r,o,i=null,a=0,c=0,u=d(),l=w.radius,s=w.units,f=function(t){return Math.round(t)},g=2,p=4,m="start",y=1,v=!0;return t.distance=function(n){return arguments.length?(e=+n,t):e},t.extent=function(n){return arguments.length?(i=n,t):i},t.label=function(n){return arguments.length?(o=n,t):o},t.labelAnchor=function(n){return arguments.length?(m=n,t):m},t.left=function(n){return arguments.length?(a=+n>1?1:+n<0?0:+n,t):a},t.orient=function(n){return arguments.length?(u=n(),t):1===u?"bottom":"top"},t.projection=function(e){return arguments.length?(n=e,t):n},t.radius=function(n){return arguments.length?(l=+n,t):l},t.size=function(n){return arguments.length?(i=[[0,0],n],t):i[1]},t.top=function(n){return arguments.length?(c=+n>1?1:+n<0?0:+n,t):c},t.tickFormat=function(n){return arguments.length?(f=n,t):f},t.tickPadding=function(n){return arguments.length?(g=+n,t):g},t.tickSize=function(n){return arguments.length?(p=+n,t):p},t.tickValues=function(n){return arguments.length?(r=n,t):r},t.units=function(n){var e;return arguments.length?(e=n,s=e.units,l=e.radius,t):s},t.zoomClamp=function(n){return arguments.length?(v=!!n,t):v},t.zoomFactor=function(n){return arguments.length?(y=+n,t):y},t}function p(){return-1}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 m,y,v,M=new n,S={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)}},x={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}(),P={sphere:function(t){},point:function(t){},lineStart:c,lineEnd:function(t){},polygonStart:function(t){},polygonEnd:function(t){}},C=[null,null],b={type:"LineString",coordinates:C},w={units:"kilometers",radius:6371.0088},z={units:"feet",radius:20902259.664},E={units:"meters",radius:6371008.8},L={units:"miles",radius:3958.7613};t.geoScaleBar=g,t.geoScaleBottom=d,t.geoScaleTop=p,t.geoScaleFeet=z,t.geoScaleKilometers=w,t.geoScaleMeters=E,t.geoScaleMiles=L,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&&x.hasOwnProperty(t.type)&&x[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&&S.hasOwnProperty(t.type)?S[t.type](t,n):r(t,n)}function c(){P.point=l,P.lineEnd=u}function u(){P.point=P.lineEnd=function(t){}}function l(t,n){t*=Math.PI/180,n*=Math.PI/180,m=t,y=Math.sin(n),v=Math.cos(n),P.point=s}function s(t,n){t*=Math.PI/180,n*=Math.PI/180;var e=Math.sin(n),r=Math.cos(n),o=Math.abs(t-m),i=Math.cos(o),a=Math.sin(o),c=r*a,u=v*e-y*r*i,l=y*e+v*r*i;k.add(Math.atan2(Math.sqrt(c*c+u*u),l)),m=t,y=e,v=r}function f(t){return k.reset(),a(t,P),+k}function h(t,n){return C[0]=t,C[1]=n,f(b)}function d(){return 1}function g(){function t(t){o=null===o?null:o||s.charAt(0).toUpperCase()+s.slice(1);var d=i[1][0]-i[0][0],M=i[1][1]-i[0][1],S=i[0][0]+d*a,x=i[0][1]+M*c,k=n.invert([S,x]),P=0,C=0;if(e)P=e,C=P/(h(k,n.invert([S+1,x]))*l);else for(var b=.01,w=60/(v?1:y),z=0,E=[1,2,4,5];C<w&&z<100;){for(var F=0,L=E.length;F<L&&(P=b*E[F],!((C=P/(h(k,n.invert([S+1,x]))*l))>=w));F++);b*=10,z++}var A=P/(v?y:1),I=null===r?[]:r||[0,A/4,A/2,A],O=function(t){return t*C/(P/y)},j=t.selection?t.selection():t,B=j.selectAll(".label").data([o]),_=j.selectAll(".domain").data([null]),q=j.selectAll(".tick").data(I,O).order(),G=q.exit(),K=q.enter().append("g").attr("class","tick"),T=q.select("line"),U=q.select("text"),V=q.select("rect");j.attr("font-family","sans-serif").attr("transform","translate(".concat([S,x],")")),_=_.merge(_.enter().insert("path",".tick").attr("class","domain").attr("fill","none").attr("stroke","currentColor")),q=q.merge(K),T=T.merge(K.append("line").attr("stroke","currentColor").attr("y2",p*u)),U=U.merge(K.append("text").attr("fill","currentColor").attr("y",p*u+g*u).attr("font-size",10).attr("text-anchor","middle").attr("dy","".concat(1===u?.71:0,"em"))),V=V.merge(K.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:O(I[n+1]-t)}).attr("y",1===u?0:-p).attr("height",p)),t!==j&&(q=q.transition(t),_=_.transition(t),V=V.transition(t),G=G.transition(t).attr("opacity",1e-6).attr("transform",function(t){return"translate(".concat(O(t),")")}),K.attr("opacity",1e-6).attr("transform",function(t){return"translate(".concat(O(t),")")})),G.remove(),_.attr("d","M".concat(O(0),",").concat(p*u," L").concat(O(0),",0 L").concat(O(A),",0 L").concat(O(A),",").concat(p*u)),q.attr("transform",function(t){return"translate(".concat(O(t),")")}).attr("opacity",1),T.attr("y2",p*u),U.attr("y",p*u+g*u).text(f),V.attr("fill",function(t,n){return n%2==0?"currentColor":"#fff"}).attr("width",function(t,n,e){return n===e.length-1?0:O(I[n+1]-t)}).attr("y",1===u?0:-p).attr("height",p),null===B?B.remove():B.enter().append("text").attr("class","label").attr("fill","currentColor").attr("font-size",12).attr("dy","-0.32em").merge(B).attr("x","start"===m?0:O("middle"===m?A/2:A)).attr("y",1===u?0:"1.3em").attr("text-anchor",m).text(function(t){return t})}var n,e,r,o,i=null,a=0,c=0,u=d(),l=w.radius,s=w.units,f=function(t){return+t.toFixed(2)},g=2,p=4,m="start",y=1,v=!0;return t.distance=function(n){return arguments.length?(e=+n,t):e},t.extent=function(n){return arguments.length?(i=n,t):i},t.label=function(n){return arguments.length?(o=n,t):o},t.labelAnchor=function(n){return arguments.length?(m=n,t):m},t.left=function(n){return arguments.length?(a=+n>1?1:+n<0?0:+n,t):a},t.orient=function(n){return arguments.length?(u=n(),t):1===u?"bottom":"top"},t.projection=function(e){return arguments.length?(n=e,t):n},t.radius=function(n){return arguments.length?(l=+n,t):l},t.size=function(n){return arguments.length?(i=[[0,0],n],t):i[1]},t.top=function(n){return arguments.length?(c=+n>1?1:+n<0?0:+n,t):c},t.tickFormat=function(n){return arguments.length?(f=n,t):f},t.tickPadding=function(n){return arguments.length?(g=+n,t):g},t.tickSize=function(n){return arguments.length?(p=+n,t):p},t.tickValues=function(n){return arguments.length?(r=n,t):r},t.units=function(n){var e;return arguments.length?(e=n,s=e.units,l=e.radius,t):s},t.zoomClamp=function(n){return arguments.length?(v=!!n,t):v},t.zoomFactor=function(n){return arguments.length?(y=+n,t):y},t}function p(){return-1}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 m,y,v,M=new n,S={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)}},x={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}(),P={sphere:function(t){},point:function(t){},lineStart:c,lineEnd:function(t){},polygonStart:function(t){},polygonEnd:function(t){}},C=[null,null],b={type:"LineString",coordinates:C},w={units:"kilometers",radius:6371.0088},z={units:"feet",radius:20902259.664},E={units:"meters",radius:6371008.8},F={units:"miles",radius:3958.7613};t.geoScaleBar=g,t.geoScaleBottom=d,t.geoScaleTop=p,t.geoScaleFeet=z,t.geoScaleKilometers=w,t.geoScaleMeters=E,t.geoScaleMiles=F,Object.defineProperty(t,"__esModule",{value:!0})});
{
"name": "d3-geo-scale-bar",
"version": "1.1.1",
"version": "1.1.2",
"description": "Displays automatic scale bars for projected geospatial data.",

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

@@ -10,7 +10,7 @@ # d3-geo-scale-bar

```html
<script src="https://unpkg.com/d3-geo-scale-bar@1.1.1/build/d3-geo-scale-bar.min.js"></script>
<script src="https://unpkg.com/d3-geo-scale-bar@1.1.2/build/d3-geo-scale-bar.min.js"></script>
<script>
const projection = d3.geoMercator()
.fitSize(width, height], geoJSON);
.fitSize([width, height], geoJSON);

@@ -17,0 +17,0 @@ const scaleBar = d3.geoScaleBar()

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

distance,
tickFormat = d => Math.round(d),
tickFormat = d => +d.toFixed(2),
tickPadding = 2,

@@ -17,0 +17,0 @@ tickSize = 4,

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc