Socket
Socket
Sign inDemoInstall

d3-geo-scale-bar

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

d3-geo-scale-bar - npm Package Compare versions

Comparing version 0.4.0 to 0.4.1

10

build/d3-geo-scale-bar.js

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

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

@@ -298,4 +298,8 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :

labelText.attr("x", labelAnchor === "start" ? 0 : labelAnchor === "middle" ? scale(tickMax / 2) : scale(tickMax)).attr("class", "label").attr("fill", "#000").attr("text-anchor", labelAnchor).attr("font-size", 14).attr("font-family", "sans-serif").attr("y", -4);
labelText.text(label || capitalizeFirstLetter(units));
if (label === null) {
labelText.remove();
} else {
label = label || capitalizeFirstLetter(units);
labelText.attr("x", labelAnchor === "start" ? 0 : labelAnchor === "middle" ? scale(tickMax / 2) : scale(tickMax)).attr("class", "label").attr("fill", "#000").attr("text-anchor", labelAnchor).attr("font-size", 14).attr("font-family", "sans-serif").attr("y", -4).text(label);
}
}

@@ -302,0 +306,0 @@

@@ -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&&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&&m.hasOwnProperty(t.type)?m[t.type](t,n):r(t,n)}function u(){b.point=l,b.lineEnd=c}function c(){b.point=b.lineEnd=function(t){}}function l(t,n){t*=Math.PI/180,n*=Math.PI/180,d=t,p=Math.sin(n),v=Math.cos(n),b.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-d),i=Math.cos(o),a=Math.sin(o),u=r*a,c=v*e-p*r*i,l=p*e+v*r*i;x.add(Math.atan2(Math.sqrt(u*u+c*c),l)),d=t,p=e,v=r}function f(t){return x.reset(),a(t,b),+x}function h(t,n){return P[0]=t,P[1]=n,f(S)}function g(){function t(t){var y=u[1][0]-u[0][0],m=u[1][1]-u[0][1];t.attr("width",y).attr("height",m);var M=u[0][0]+y*l,x=u[0][1]+m*s,b=r.invert([M,x]);o=o||Math.pow(10,n(h(r.invert(u[0]),r.invert([u[1][0],u[0][1]]))*g)-1);var P=o/(h(b,r.invert([M+1,x]))*g),S=function(t){return t*P/(o/v)},w=o/v,k=null===i?[]:i||[0,w/4,w/2,w],E=t.select("g");E._groups[0][0]||(E=t.append("g")),E.attr("transform","translate(".concat([M,x],")"));var O=E.select(".baseline");O._groups[0][0]||(O=E.append("rect").attr("class","baseline")),O.attr("fill","black").attr("height",c).attr("width",S(w));var _=E.selectAll(".rectangle").data(k.map(function(t,n,e){return[t,e[n+1]]}).filter(function(t,n,e){return n!==e.length-1}));_.exit().remove(),_.enter().append("rect").attr("class","rectangle").attr("height",c).attr("stroke","#000").attr("fill",function(t,n){return n%2==0?"#000":"#fff"}).merge(_).attr("x",function(t){return S(t[0])}).attr("width",function(t){return S(t[1]-t[0])});var j=E.selectAll(".value").data(k);j.exit().remove(),j.enter().append("text").attr("class","value").attr("text-anchor","middle").attr("font-family","sans-serif").attr("font-size",12).merge(j).attr("x",S).attr("y",c+11).text(d);var A=E.select(".label");A._groups[0][0]||(A=E.append("text").attr("class","label")),A.attr("x","start"===p?0:S("middle"===p?w/2:w)).attr("class","label").attr("fill","#000").attr("text-anchor",p).attr("font-size",14).attr("font-family","sans-serif").attr("y",-4),A.text(a||e(f))}function n(t){return Math.floor(t).toString().length}function e(t){return t.charAt(0).toUpperCase()+t.slice(1)}var r,o,i,a,u=null,c=4,l=0,s=0,f="kilometers",g=6371,d=function(t){return Math.round(t)},p="start",v=1,y={miles:{radius:3959},kilometers:{radius:6371}};return t.extent=function(n){return arguments.length?(u=n,t):u},t.size=function(n){return arguments.length?(u=[[0,0],n],t):u[1]},t.projection=function(n){return arguments.length?(r=n,t):r},t.units=function(n){return arguments.length?(f=n,Object.keys(y).includes(n)&&(g=y[n].radius),t):f},t.distance=function(n){return arguments.length?(o=+n,t):o},t.radius=function(n){return arguments.length?(g=+n,t):g},t.tickValues=function(n){return arguments.length?(i=n,t):i},t.tickFormat=function(n){return arguments.length?(d=n,t):d},t.label=function(n){return arguments.length?(a=n,t):a},t.labelAnchor=function(n){return arguments.length?(p=n,t):p},t.height=function(n){return arguments.length?(c=+n,t):c},t.left=function(n){return arguments.length?(l=n>1?1:n<0?0:+n,t):l},t.top=function(n){return arguments.length?(s=n>1?1:n<0?0:+n,t):s},t.scaleFactor=function(n){return arguments.length?(v=n,t):v},t}n.prototype={constructor:n,reset:function(){this.s=this.t=0},add:function(t){e(y,t,this.t),e(this,y.s,this.s),this.s?this.t+=y.t:this.s=y.t},valueOf:function(){return this.s}};var d,p,v,y=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)}},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)}},x=function(){return new n}(),b={sphere:function(t){},point:function(t){},lineStart:u,lineEnd:function(t){},polygonStart:function(t){},polygonEnd:function(t){}},P=[null,null],S={type:"LineString",coordinates:P};t.geoScaleBar=g,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&&m.hasOwnProperty(t.type)?m[t.type](t,n):r(t,n)}function u(){b.point=c,b.lineEnd=l}function l(){b.point=b.lineEnd=function(t){}}function c(t,n){t*=Math.PI/180,n*=Math.PI/180,d=t,p=Math.sin(n),v=Math.cos(n),b.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-d),i=Math.cos(o),a=Math.sin(o),u=r*a,l=v*e-p*r*i,c=p*e+v*r*i;x.add(Math.atan2(Math.sqrt(u*u+l*l),c)),d=t,p=e,v=r}function f(t){return x.reset(),a(t,b),+x}function h(t,n){return P[0]=t,P[1]=n,f(S)}function g(){function t(t){var y=u[1][0]-u[0][0],m=u[1][1]-u[0][1];t.attr("width",y).attr("height",m);var M=u[0][0]+y*c,x=u[0][1]+m*s,b=r.invert([M,x]);o=o||Math.pow(10,n(h(r.invert(u[0]),r.invert([u[1][0],u[0][1]]))*g)-1);var P=o/(h(b,r.invert([M+1,x]))*g),S=function(t){return t*P/(o/v)},w=o/v,k=null===i?[]:i||[0,w/4,w/2,w],E=t.select("g");E._groups[0][0]||(E=t.append("g")),E.attr("transform","translate(".concat([M,x],")"));var O=E.select(".baseline");O._groups[0][0]||(O=E.append("rect").attr("class","baseline")),O.attr("fill","black").attr("height",l).attr("width",S(w));var _=E.selectAll(".rectangle").data(k.map(function(t,n,e){return[t,e[n+1]]}).filter(function(t,n,e){return n!==e.length-1}));_.exit().remove(),_.enter().append("rect").attr("class","rectangle").attr("height",l).attr("stroke","#000").attr("fill",function(t,n){return n%2==0?"#000":"#fff"}).merge(_).attr("x",function(t){return S(t[0])}).attr("width",function(t){return S(t[1]-t[0])});var j=E.selectAll(".value").data(k);j.exit().remove(),j.enter().append("text").attr("class","value").attr("text-anchor","middle").attr("font-family","sans-serif").attr("font-size",12).merge(j).attr("x",S).attr("y",l+11).text(d);var A=E.select(".label");A._groups[0][0]||(A=E.append("text").attr("class","label")),null===a?A.remove():(a=a||e(f),A.attr("x","start"===p?0:S("middle"===p?w/2:w)).attr("class","label").attr("fill","#000").attr("text-anchor",p).attr("font-size",14).attr("font-family","sans-serif").attr("y",-4).text(a))}function n(t){return Math.floor(t).toString().length}function e(t){return t.charAt(0).toUpperCase()+t.slice(1)}var r,o,i,a,u=null,l=4,c=0,s=0,f="kilometers",g=6371,d=function(t){return Math.round(t)},p="start",v=1,y={miles:{radius:3959},kilometers:{radius:6371}};return t.extent=function(n){return arguments.length?(u=n,t):u},t.size=function(n){return arguments.length?(u=[[0,0],n],t):u[1]},t.projection=function(n){return arguments.length?(r=n,t):r},t.units=function(n){return arguments.length?(f=n,Object.keys(y).includes(n)&&(g=y[n].radius),t):f},t.distance=function(n){return arguments.length?(o=+n,t):o},t.radius=function(n){return arguments.length?(g=+n,t):g},t.tickValues=function(n){return arguments.length?(i=n,t):i},t.tickFormat=function(n){return arguments.length?(d=n,t):d},t.label=function(n){return arguments.length?(a=n,t):a},t.labelAnchor=function(n){return arguments.length?(p=n,t):p},t.height=function(n){return arguments.length?(l=+n,t):l},t.left=function(n){return arguments.length?(c=n>1?1:n<0?0:+n,t):c},t.top=function(n){return arguments.length?(s=n>1?1:n<0?0:+n,t):s},t.scaleFactor=function(n){return arguments.length?(v=n,t):v},t}n.prototype={constructor:n,reset:function(){this.s=this.t=0},add:function(t){e(y,t,this.t),e(this,y.s,this.s),this.s?this.t+=y.t:this.s=y.t},valueOf:function(){return this.s}};var d,p,v,y=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)}},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)}},x=function(){return new n}(),b={sphere:function(t){},point:function(t){},lineStart:u,lineEnd:function(t){},polygonStart:function(t){},polygonEnd:function(t){}},P=[null,null],S={type:"LineString",coordinates:P};t.geoScaleBar=g,Object.defineProperty(t,"__esModule",{value:!0})});
{
"name": "d3-geo-scale-bar",
"version": "0.4.0",
"version": "0.4.1",
"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.4.0/build/d3-geo-scale-bar.min.js"></script>
<script src="https://unpkg.com/d3-geo-scale-bar@0.4.1/build/d3-geo-scale-bar.min.js"></script>
<script>

@@ -103,3 +103,3 @@

If a <i>label</i> string is specified, updates the text in the scale bar's label to the specified string. Defaults to the capitalized unit, e.g. "Kilometers". If *label* is not specified, returns the current label.
If a <i>label</i> string is specified, updates the text in the scale bar's label to the specified string. Defaults to the capitalized unit, e.g. "Kilometers". If label is specified as <i>null</i>, removes the label. If <i>label</i> is not specified, returns the current label.

@@ -106,0 +106,0 @@ <a name="scaleBar_labelAnchor" href="#scaleBar_labelAnchor">#</a> <i>scaleBar</i>.<b>labelAnchor</b>([<i>anchor</i>]) [<>](https://github.com/HarryStevens/d3-geo-scale-bar/blob/master/src/geoScaleBar.js#L126 "Source")

@@ -94,12 +94,20 @@ import { default as geoDistance } from "./geo/distance";

}
labelText
.attr("x", labelAnchor === "start" ? 0 : labelAnchor === "middle" ? scale(tickMax / 2) : scale(tickMax))
.attr("class", "label")
.attr("fill", "#000")
.attr("text-anchor", labelAnchor)
.attr("font-size", 14)
.attr("font-family", "sans-serif")
.attr("y", -4);
if (label === null){
labelText.remove();
}
else {
label = label || capitalizeFirstLetter(units);
labelText
.attr("x", labelAnchor === "start" ? 0 : labelAnchor === "middle" ? scale(tickMax / 2) : scale(tickMax))
.attr("class", "label")
.attr("fill", "#000")
.attr("text-anchor", labelAnchor)
.attr("font-size", 14)
.attr("font-family", "sans-serif")
.attr("y", -4)
.text(label);
}
labelText.text(label || capitalizeFirstLetter(units));
}

@@ -106,0 +114,0 @@

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc