UNPKG

@redsift/d3-rs-svg

Version:

Creates a SVG element using D3v4.

2 lines (1 loc) 2.66 kB
(function(a,b){"object"==typeof exports&&"undefined"!=typeof module?b(exports,require("d3-selection")):"function"==typeof define&&define.amd?define(["exports","d3-selection"],b):(a=a||self,b(a.D3RsSvg={},a.d3Selection))})(this,function(a,b){"use strict";a.version="0.8.0",a.html=function(a){function c(){n=f-l-j}function d(){o=h-i-k}function e(c){var d=c.selection?c.selection():c,j=void 0!==c.selection;d.each(function(){var d=b.select(this),k=d.select(e.self());if(k.empty()){var n=(null==a?"":a+"-")+"title",o=(null==a?"":a+"-")+"desc";k=d.append("svg").attr("version","1.1").attr("xmlns","http://www.w3.org/2000/svg").attr("xmlns:xlink","http://www.w3.org/1999/xlink").attr("preserveAspectRatio","xMidYMid meet").attr("aria-labelledby",n).attr("aria-describedby",o).attr("id",a),k.append("title").attr("id",n),k.append("desc").attr("id",o),k.append("defs"),k.append("rect").attr("class","background"),k.append("g").attr("class","svg-child")}k.attr("overflow",v?"visible":"hidden");var w=k.select("defs"),x=w.selectAll("style").data(p?[p]:[]);x.exit().remove(),x=x.enter().append("style").attr("type","text/css").merge(x),x.text(p),k.attr("role",t),k.select("title").text(r),k.select("desc").text(s);var y=k.select("rect.background").attr("width",null==q?null:f*m).attr("height",null==q?null:h*m);k.attr("class",u);var z=k.select(e.child());!0==j&&(k=k.transition(c),z=z.transition(c),y=y.transition(c)),k.attr("width",f*m).attr("height",h*m).attr("viewBox","0 0 "+f+" "+h),z.attr("transform","translate("+l+","+i+")"),y.attr("fill",q)})}var f=300,h=150,i=16,j=16,k=16,l=16,m=1,n=-1,o=-1,p=null,q=null,r=null,s=null,t="img",u="svg-svg",v=!1;return c(),d(),e.self=function(){return"svg"+(a?"#"+a:"")},e.child=function(){return"g.svg-child"},e.childDefs=function(){return"defs"},e.childWidth=function(){return n},e.childHeight=function(){return o},e.id=function(){return a},e.classed=function(a){return arguments.length?(u=a,e):u},e.style=function(a){return arguments.length?(p=a,e):p},e.background=function(a){return arguments.length?(q=a,e):q},e.width=function(a){return arguments.length?(f=a,c(),e):f},e.height=function(a){return arguments.length?(h=a,d(),e):f},e.scale=function(a){return arguments.length?(m=a,e):m},e.title=function(a){return arguments.length?(r=a,e):r},e.desc=function(a){return arguments.length?(s=a,e):s},e.role=function(a){return arguments.length?(t=a,e):t},e.overflow=function(a){return arguments.length?(v=a,e):v},e.margin=function(a){return arguments.length?(void 0===a.top?(i=a,j=a,k=a,l=a):(i=a.top,j=a.right,k=a.bottom,l=a.left),c(),d(),e):{top:i,right:j,bottom:k,left:l}},e},Object.defineProperty(a,"__esModule",{value:!0})});