NuclearDispersionSystem/ant-design-vue-jeecg/node_modules/contour_plot/build/contour_plot.min.js
2023-09-14 14:47:11 +08:00

1 line
5.0 KiB
JavaScript

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define("contour_plot",["exports"],e):e(t.contour_plot={})}(this,function(t){"use strict";function e(t,e,n,r){r=r||{};var o=r.maxIterations||100,a=r.tolerance||1e-10,i=t(e),l=t(n),s=n-e;if(i*l>0)throw"Initial bisect points must have opposite signs";if(0===i)return e;if(0===l)return n;for(var u=0;u<o;++u){s/=2;var f=e+s,c=t(f);if(c*i>=0&&(e=f),Math.abs(s)<a||0===c)return f}return e+s}function n(t,e){var n=e||r(t),o=[],a=n[0],i=n[1],l=0,s=0,u=NaN,d=NaN,h=0;do h=0,t(a-1,i-1)&&(h+=1),t(a,i-1)&&(h+=2),t(a-1,i)&&(h+=4),t(a,i)&&(h+=8),6===h?(l=d===-1?-1:1,s=0):9===h?(l=0,s=1===u?-1:1):(l=f[h],s=c[h]),l!=u&&s!=d?(o.push([a,i]),u=l,d=s):o.push([a,i]),a+=l,i+=s;while(n[0]!=a||n[1]!=i);return o}function r(t){for(var e=0,n=0;;){if(t(e,n))return[e,n];0===e?(e=n+1,n=0):(e-=1,n+=1)}}function o(t,e,n,r){var o=n.range(),a=r.range();return function(i,l){return!(i<o[0]||i>o[1]||l<a[0]||l>a[1])&&t(n.invert(i),r.invert(l))<e}}function a(t,n,r,o,a){for(var i=o.range(),l=a.range(),s=function(e){return t(o.invert(d),a.invert(e))-r},u=function(e){return t(o.invert(e),a.invert(h))-r},f=0;f<n.length;++f){var c=n[f],d=c[0],h=c[1];if(!(d<=i[0]||d>=i[1]||h<=l[0]||h>=l[1])){for(var v=s(h),p={maxIterations:9},g=.5;g<=3;g+=.5){if(s(h-g)*v<0)h=e(s,h,h-g,p);else if(u(d-g)*v<0)d=e(u,d,d-g,p);else if(s(h+g)*v<0)h=e(s,h,h+g,p);else{if(!(u(d+g)*v<0))continue;d=e(u,d,d+g,p)}break}c[0]=d,c[1]=h}}}function i(t,e,n,r){var o,a,i,l=e.range(),s=n.range();o=a=t(e.invert(l[0]),n.invert(s[0]));for(var u=s[0];u<s[1]+1;++u)for(var f=l[0];f<l[1]+1;++f)i=t(e.invert(f),n.invert(u)),a=Math.min(i,a),o=Math.max(i,o);for(var c=[],d=Math.log(o-Math.floor(a)),h=Math.ceil(Math.exp(d/r)),v=Math.pow(h,Math.ceil(d/Math.log(h))),p=0;p<r;++p){var g=Math.floor(a)+v;if(g<a)break;c.push(g),v/=h}return c}function l(t,e,n){e=Math.floor(e),n=Math.floor(n);for(var r=0;;){if(r+=1,!t(e+r,n))return[e+r,n];if(!t(e,n+r))return[e,n+r]}}function s(t,e,r,s,u){for(var f=i(t,e,r,s),c=[],d=0;d<f.length;++d){var h=f[d],v=o(t,h,e,r),p=[];if(u)for(var g=[],y=0;y<u.length;++y){for(var x=l(v,e(u[y].x),r(u[y].y)),m=n(v,x),b=!1,M=0;M<m.length;++M){for(var w=m[M],k=0;k<g.length;++k){var N=g[k];if(w[0]==N[0]&&w[1]==N[1]){b=!0;break}}if(b)break}b||(g.push(x),a(t,m,h,e,r),p.length&&p.push(null),p=p.concat(m))}else p=n(v),a(t,p,h,e,r);c.push(p)}return{paths:c,levels:f}}function u(){function t(t){var u=t.nodes()[0].offsetWidth,f=.75*u,c=e?24:0,d=d3.scaleLinear().range([c,f-c]).domain(r),h=d3.scaleLinear().range([c,u-c]).domain(o);d3.select("body").selectAll(".contour_tooltip").data([0]).enter().append("div").attr("class","contour_tooltip").style("font-size","12px").style("position","absolute").style("text-align","center").style("width","128px").style("height","32px").style("background","#333").style("color","#ddd").style("padding","0px").style("border","0px").style("border-radius","8px").style("opacity","0");var v=d3.selectAll(".contour_tooltip");t.selectAll("svg").data([0]).enter().append("svg");var p=t.selectAll("svg").data([0]);p.attr("width",u).attr("height",f).on("mouseover",function(){v.transition().duration(400).style("opacity",.9),v.style("z-index","")}).on("mousemove",function(){var t=d3.mouse(this),e=h.invert(t[0]),r=d.invert(t[1]),o=n(e,r);v.style("left",d3.event.pageX+"px").style("top",d3.event.pageY-44+"px"),v.html("x = "+e.toFixed(2)+" y = "+r.toFixed(2)+"<br>f(x,y) = "+o.toFixed(2))}).on("mouseout",function(){v.transition().duration(400).style("opacity",0),v.style("z-index",-1)});var g=s(n,h,d,i,a),y=g.paths,x=(g.levels,d3.line().x(function(t){return t[0]}).y(function(t){return t[1]}).curve(d3.curveLinearClosed).defined(function(t){return t})),m=p.append("g");if(m.selectAll("path").data(y).enter().append("path").attr("d",x).style("fill",function(t,e){return l(e)}).style("stroke-width",1.5).style("stroke","white").on("mouseover",function(){d3.select(this).style("stroke-width","4")}).on("mouseout",function(){d3.select(this).style("stroke-width","1.5")}),e){var b=d3.axisBottom().scale(h),M=d3.axisLeft().scale(d);p.append("g").attr("class","axis").attr("transform","translate(0,"+(f-1*c)+")").call(b),p.append("g").attr("class","axis").attr("transform","translate("+c+",0)").call(M)}return{xScale:h,yScale:d,svg:p}}var e=!1,n=function(t,e){return(1-t)*(1-t)+100*(e-t*t)*(e-t*t)},r=[3,-3],o=[-2,2],a=null,i=14,l=d3.scaleLinear().domain([0,i]).range(["white",d3.schemeCategory10[0]]);return t.drawAxis=function(n){return arguments.length?(e=n,t):e},t.xDomain=function(e){return arguments.length?(o=e,t):o},t.yDomain=function(e){return arguments.length?(r=e,t):r},t.colourScale=function(e){return arguments.length?(l=e,t):l},t.contourCount=function(e){return arguments.length?(i=e,t):i},t.minima=function(e){return arguments.length?(a=e,t):a},t.f=function(e){return arguments.length?(n=e,t):n},t}var f=[1,0,1,1,-1,0,-1,1,0,0,0,0,-1,0,-1,NaN],c=[0,-1,0,0,0,-1,0,0,1,-1,1,1,0,-1,0,NaN],d="0.0.1";t.version=d,t.isoline=o,t.smoothPoints=a,t.getLogLevels=i,t.getContours=s,t.ContourPlot=u});