36 lines
17 KiB
JavaScript
36 lines
17 KiB
JavaScript
import{I as it,c as B,s as ut,g as pt,p as ft,q as yt,a as mt,b as dt,m as gt,j as _t,l as J,r as vt,h as nt,i as bt,S as kt}from"./intro.stories-11dbe3c4.js";import"./dayjs.min-1b995edc.js";import{o as xt}from"./ordinal-ba9b4969.js";import{a as St}from"./array-9f3ba611.js";import{c as M}from"./path-53f90ab3.js";import{a as lt}from"./arc-5437839e.js";import"./chunk-S4VUQJ4A-9f830f12.js";import"./iframe-da7e4a3d.js";import"../sb-preview/runtime.js";import"./index-3006e466.js";import"./_commonjsHelpers-de833af9.js";import"./index-d37d4223.js";import"./index-e04ae519.js";import"./index-356e4a49.js";import"./jsx-runtime-cc7d3d6f.js";import"./_getTag-edecb89a.js";import"./isSymbol-50749e90.js";import"./isObject-32699ff3.js";import"./toString-25ea340b.js";import"./Table-531e15c2.js";import"./parseCss-0603dd28.js";import"./index-f779c4fe.js";import"./_color-087aa1f8.js";import"./index-e0c548e1.js";import"./init-77b53fdd.js";function wt(t,u){return u<t?-1:u>t?1:u>=t?0:NaN}function At(t){return t}function Et(){var t=At,u=wt,_=null,b=M(0),x=M(it),S=M(0);function o(a){var p,h=(a=St(a)).length,w,L,N=0,v=new Array(h),A=new Array(h),T=+b.apply(this,arguments),D=Math.min(it,Math.max(-it,x.apply(this,arguments)-T)),W,C=Math.min(Math.abs(D)/h,S.apply(this,arguments)),I=C*(D<0?-1:1),m;for(p=0;p<h;++p)(m=A[v[p]=p]=+t(a[p],p,a))>0&&(N+=m);for(u!=null?v.sort(function(E,d){return u(A[E],A[d])}):_!=null&&v.sort(function(E,d){return _(a[E],a[d])}),p=0,L=N?(D-h*I)/N:0;p<h;++p,T=W)w=v[p],m=A[w],W=T+(m>0?m*L:0)+I,A[w]={data:a[w],index:p,value:m,startAngle:T,endAngle:W,padAngle:C};return A}return o.value=function(a){return arguments.length?(t=typeof a=="function"?a:M(+a),o):t},o.sortValues=function(a){return arguments.length?(u=a,_=null,o):u},o.sort=function(a){return arguments.length?(_=a,u=null,o):_},o.startAngle=function(a){return arguments.length?(b=typeof a=="function"?a:M(+a),o):b},o.endAngle=function(a){return arguments.length?(x=typeof a=="function"?a:M(+a),o):x},o.padAngle=function(a){return arguments.length?(S=typeof a=="function"?a:M(+a),o):S},o}var rt=function(){var t=function(d,e,i,s){for(i=i||{},s=d.length;s--;i[d[s]]=e);return i},u=[1,4],_=[1,5],b=[1,6],x=[1,7],S=[1,9],o=[1,11,13,15,17,19,20,26,27,28,29],a=[2,5],p=[1,6,11,13,15,17,19,20,26,27,28,29],h=[26,27,28],w=[2,8],L=[1,18],N=[1,19],v=[1,20],A=[1,21],T=[1,22],D=[1,23],W=[1,28],C=[6,26,27,28,29],I={trace:function(){},yy:{},symbols_:{error:2,start:3,eol:4,directive:5,PIE:6,document:7,showData:8,line:9,statement:10,txt:11,value:12,title:13,title_value:14,acc_title:15,acc_title_value:16,acc_descr:17,acc_descr_value:18,acc_descr_multiline_value:19,section:20,openDirective:21,typeDirective:22,closeDirective:23,":":24,argDirective:25,NEWLINE:26,";":27,EOF:28,open_directive:29,type_directive:30,arg_directive:31,close_directive:32,$accept:0,$end:1},terminals_:{2:"error",6:"PIE",8:"showData",11:"txt",12:"value",13:"title",14:"title_value",15:"acc_title",16:"acc_title_value",17:"acc_descr",18:"acc_descr_value",19:"acc_descr_multiline_value",20:"section",24:":",26:"NEWLINE",27:";",28:"EOF",29:"open_directive",30:"type_directive",31:"arg_directive",32:"close_directive"},productions_:[0,[3,2],[3,2],[3,2],[3,3],[7,0],[7,2],[9,2],[10,0],[10,2],[10,2],[10,2],[10,2],[10,1],[10,1],[10,1],[5,3],[5,5],[4,1],[4,1],[4,1],[21,1],[22,1],[25,1],[23,1]],performAction:function(e,i,s,n,l,r,c){var f=r.length-1;switch(l){case 4:n.setShowData(!0);break;case 7:this.$=r[f-1];break;case 9:n.addSection(r[f-1],n.cleanupValue(r[f]));break;case 10:this.$=r[f].trim(),n.setDiagramTitle(this.$);break;case 11:this.$=r[f].trim(),n.setAccTitle(this.$);break;case 12:case 13:this.$=r[f].trim(),n.setAccDescription(this.$);break;case 14:n.addSection(r[f].substr(8)),this.$=r[f].substr(8);break;case 21:n.parseDirective("%%{","open_directive");break;case 22:n.parseDirective(r[f],"type_directive");break;case 23:r[f]=r[f].trim().replace(/'/g,'"'),n.parseDirective(r[f],"arg_directive");break;case 24:n.parseDirective("}%%","close_directive","pie");break}},table:[{3:1,4:2,5:3,6:u,21:8,26:_,27:b,28:x,29:S},{1:[3]},{3:10,4:2,5:3,6:u,21:8,26:_,27:b,28:x,29:S},{3:11,4:2,5:3,6:u,21:8,26:_,27:b,28:x,29:S},t(o,a,{7:12,8:[1,13]}),t(p,[2,18]),t(p,[2,19]),t(p,[2,20]),{22:14,30:[1,15]},{30:[2,21]},{1:[2,1]},{1:[2,2]},t(h,w,{21:8,9:16,10:17,5:24,1:[2,3],11:L,13:N,15:v,17:A,19:T,20:D,29:S}),t(o,a,{7:25}),{23:26,24:[1,27],32:W},t([24,32],[2,22]),t(o,[2,6]),{4:29,26:_,27:b,28:x},{12:[1,30]},{14:[1,31]},{16:[1,32]},{18:[1,33]},t(h,[2,13]),t(h,[2,14]),t(h,[2,15]),t(h,w,{21:8,9:16,10:17,5:24,1:[2,4],11:L,13:N,15:v,17:A,19:T,20:D,29:S}),t(C,[2,16]),{25:34,31:[1,35]},t(C,[2,24]),t(o,[2,7]),t(h,[2,9]),t(h,[2,10]),t(h,[2,11]),t(h,[2,12]),{23:36,32:W},{32:[2,23]},t(C,[2,17])],defaultActions:{9:[2,21],10:[2,1],11:[2,2],35:[2,23]},parseError:function(e,i){if(i.recoverable)this.trace(e);else{var s=new Error(e);throw s.hash=i,s}},parse:function(e){var i=this,s=[0],n=[],l=[null],r=[],c=this.table,f="",F=0,U=0,Q=2,q=1,ot=r.slice.call(arguments,1),y=Object.create(this.lexer),j={yy:{}};for(var X in this.yy)Object.prototype.hasOwnProperty.call(this.yy,X)&&(j.yy[X]=this.yy[X]);y.setInput(e,j.yy),j.yy.lexer=y,j.yy.parser=this,typeof y.yylloc>"u"&&(y.yylloc={});var Z=y.yylloc;r.push(Z);var ct=y.options&&y.options.ranges;typeof j.yy.parseError=="function"?this.parseError=j.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function ht(){var O;return O=n.pop()||y.lex()||q,typeof O!="number"&&(O instanceof Array&&(n=O,O=n.pop()),O=i.symbols_[O]||O),O}for(var g,z,k,tt,R={},G,V,at,H;;){if(z=s[s.length-1],this.defaultActions[z]?k=this.defaultActions[z]:((g===null||typeof g>"u")&&(g=ht()),k=c[z]&&c[z][g]),typeof k>"u"||!k.length||!k[0]){var et="";H=[];for(G in c[z])this.terminals_[G]&&G>Q&&H.push("'"+this.terminals_[G]+"'");y.showPosition?et="Parse error on line "+(F+1)+`:
|
|
`+y.showPosition()+`
|
|
Expecting `+H.join(", ")+", got '"+(this.terminals_[g]||g)+"'":et="Parse error on line "+(F+1)+": Unexpected "+(g==q?"end of input":"'"+(this.terminals_[g]||g)+"'"),this.parseError(et,{text:y.match,token:this.terminals_[g]||g,line:y.yylineno,loc:Z,expected:H})}if(k[0]instanceof Array&&k.length>1)throw new Error("Parse Error: multiple actions possible at state: "+z+", token: "+g);switch(k[0]){case 1:s.push(g),l.push(y.yytext),r.push(y.yylloc),s.push(k[1]),g=null,U=y.yyleng,f=y.yytext,F=y.yylineno,Z=y.yylloc;break;case 2:if(V=this.productions_[k[1]][1],R.$=l[l.length-V],R._$={first_line:r[r.length-(V||1)].first_line,last_line:r[r.length-1].last_line,first_column:r[r.length-(V||1)].first_column,last_column:r[r.length-1].last_column},ct&&(R._$.range=[r[r.length-(V||1)].range[0],r[r.length-1].range[1]]),tt=this.performAction.apply(R,[f,U,F,j.yy,k[1],l,r].concat(ot)),typeof tt<"u")return tt;V&&(s=s.slice(0,-1*V*2),l=l.slice(0,-1*V),r=r.slice(0,-1*V)),s.push(this.productions_[k[1]][0]),l.push(R.$),r.push(R._$),at=c[s[s.length-2]][s[s.length-1]],s.push(at);break;case 3:return!0}}return!0}},m=function(){var d={EOF:1,parseError:function(i,s){if(this.yy.parser)this.yy.parser.parseError(i,s);else throw new Error(i)},setInput:function(e,i){return this.yy=i||this.yy||{},this._input=e,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var e=this._input[0];this.yytext+=e,this.yyleng++,this.offset++,this.match+=e,this.matched+=e;var i=e.match(/(?:\r\n?|\n).*/g);return i?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),e},unput:function(e){var i=e.length,s=e.split(/(?:\r\n?|\n)/g);this._input=e+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-i),this.offset-=i;var n=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),s.length-1&&(this.yylineno-=s.length-1);var l=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:s?(s.length===n.length?this.yylloc.first_column:0)+n[n.length-s.length].length-s[0].length:this.yylloc.first_column-i},this.options.ranges&&(this.yylloc.range=[l[0],l[0]+this.yyleng-i]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){if(this.options.backtrack_lexer)this._backtrack=!0;else return this.parseError("Lexical error on line "+(this.yylineno+1)+`. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).
|
|
`+this.showPosition(),{text:"",token:null,line:this.yylineno});return this},less:function(e){this.unput(this.match.slice(e))},pastInput:function(){var e=this.matched.substr(0,this.matched.length-this.match.length);return(e.length>20?"...":"")+e.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var e=this.match;return e.length<20&&(e+=this._input.substr(0,20-e.length)),(e.substr(0,20)+(e.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var e=this.pastInput(),i=new Array(e.length+1).join("-");return e+this.upcomingInput()+`
|
|
`+i+"^"},test_match:function(e,i){var s,n,l;if(this.options.backtrack_lexer&&(l={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(l.yylloc.range=this.yylloc.range.slice(0))),n=e[0].match(/(?:\r\n?|\n).*/g),n&&(this.yylineno+=n.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:n?n[n.length-1].length-n[n.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+e[0].length},this.yytext+=e[0],this.match+=e[0],this.matches=e,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(e[0].length),this.matched+=e[0],s=this.performAction.call(this,this.yy,this,i,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),s)return s;if(this._backtrack){for(var r in l)this[r]=l[r];return!1}return!1},next:function(){if(this.done)return this.EOF;this._input||(this.done=!0);var e,i,s,n;this._more||(this.yytext="",this.match="");for(var l=this._currentRules(),r=0;r<l.length;r++)if(s=this._input.match(this.rules[l[r]]),s&&(!i||s[0].length>i[0].length)){if(i=s,n=r,this.options.backtrack_lexer){if(e=this.test_match(s,l[r]),e!==!1)return e;if(this._backtrack){i=!1;continue}else return!1}else if(!this.options.flex)break}return i?(e=this.test_match(i,l[n]),e!==!1?e:!1):this._input===""?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+`. Unrecognized text.
|
|
`+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){var i=this.next();return i||this.lex()},begin:function(i){this.conditionStack.push(i)},popState:function(){var i=this.conditionStack.length-1;return i>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(i){return i=this.conditionStack.length-1-Math.abs(i||0),i>=0?this.conditionStack[i]:"INITIAL"},pushState:function(i){this.begin(i)},stateStackSize:function(){return this.conditionStack.length},options:{"case-insensitive":!0},performAction:function(i,s,n,l){switch(n){case 0:return this.begin("open_directive"),29;case 1:return this.begin("type_directive"),30;case 2:return this.popState(),this.begin("arg_directive"),24;case 3:return this.popState(),this.popState(),32;case 4:return 31;case 5:break;case 6:break;case 7:return 26;case 8:break;case 9:break;case 10:return this.begin("title"),13;case 11:return this.popState(),"title_value";case 12:return this.begin("acc_title"),15;case 13:return this.popState(),"acc_title_value";case 14:return this.begin("acc_descr"),17;case 15:return this.popState(),"acc_descr_value";case 16:this.begin("acc_descr_multiline");break;case 17:this.popState();break;case 18:return"acc_descr_multiline_value";case 19:this.begin("string");break;case 20:this.popState();break;case 21:return"txt";case 22:return 6;case 23:return 8;case 24:return"value";case 25:return 28}},rules:[/^(?:%%\{)/i,/^(?:((?:(?!\}%%)[^:.])*))/i,/^(?::)/i,/^(?:\}%%)/i,/^(?:((?:(?!\}%%).|\n)*))/i,/^(?:%%(?!\{)[^\n]*)/i,/^(?:[^\}]%%[^\n]*)/i,/^(?:[\n\r]+)/i,/^(?:%%[^\n]*)/i,/^(?:[\s]+)/i,/^(?:title\b)/i,/^(?:(?!\n||)*[^\n]*)/i,/^(?:accTitle\s*:\s*)/i,/^(?:(?!\n||)*[^\n]*)/i,/^(?:accDescr\s*:\s*)/i,/^(?:(?!\n||)*[^\n]*)/i,/^(?:accDescr\s*\{\s*)/i,/^(?:[\}])/i,/^(?:[^\}]*)/i,/^(?:["])/i,/^(?:["])/i,/^(?:[^"]*)/i,/^(?:pie\b)/i,/^(?:showData\b)/i,/^(?::[\s]*[\d]+(?:\.[\d]+)?)/i,/^(?:$)/i],conditions:{acc_descr_multiline:{rules:[17,18],inclusive:!1},acc_descr:{rules:[15],inclusive:!1},acc_title:{rules:[13],inclusive:!1},close_directive:{rules:[],inclusive:!1},arg_directive:{rules:[3,4],inclusive:!1},type_directive:{rules:[2,3],inclusive:!1},open_directive:{rules:[1],inclusive:!1},title:{rules:[11],inclusive:!1},string:{rules:[20,21],inclusive:!1},INITIAL:{rules:[0,5,6,7,8,9,10,12,14,16,19,22,23,24,25],inclusive:!0}}};return d}();I.lexer=m;function E(){this.yy={}}return E.prototype=I,I.Parser=E,new E}();rt.parser=rt;const Dt=rt;let K={},st=!1;const $t=function(t,u,_){gt.parseDirective(this,t,u,_)},Tt=function(t,u){t=_t.sanitizeText(t,B()),K[t]===void 0&&(K[t]=u,J.debug("Added new section :",t))},It=()=>K,Vt=function(t){st=t},Ot=function(){return st},Pt=function(t){return t.substring(0,1)===":"&&(t=t.substring(1).trim()),Number(t.trim())},Lt=function(){K={},st=!1,vt()},Nt={parseDirective:$t,getConfig:()=>B().pie,addSection:Tt,getSections:It,cleanupValue:Pt,clear:Lt,setAccTitle:ut,getAccTitle:pt,setDiagramTitle:ft,getDiagramTitle:yt,setShowData:Vt,getShowData:Ot,getAccDescription:mt,setAccDescription:dt},Wt=t=>`
|
|
.pieCircle{
|
|
stroke: ${t.pieStrokeColor};
|
|
stroke-width : ${t.pieStrokeWidth};
|
|
opacity : ${t.pieOpacity};
|
|
}
|
|
.pieOuterCircle{
|
|
stroke: ${t.pieOuterStrokeColor};
|
|
stroke-width: ${t.pieOuterStrokeWidth};
|
|
fill: none;
|
|
}
|
|
.pieTitleText {
|
|
text-anchor: middle;
|
|
font-size: ${t.pieTitleTextSize};
|
|
fill: ${t.pieTitleTextColor};
|
|
font-family: ${t.fontFamily};
|
|
}
|
|
.slice {
|
|
font-family: ${t.fontFamily};
|
|
fill: ${t.pieSectionTextColor};
|
|
font-size:${t.pieSectionTextSize};
|
|
// fill: white;
|
|
}
|
|
.legend text {
|
|
fill: ${t.pieLegendTextColor};
|
|
font-family: ${t.fontFamily};
|
|
font-size: ${t.pieLegendTextSize};
|
|
}
|
|
`,Ct=Wt;let $=B(),P;const Y=450,Ft=(t,u,_,b)=>{var x;try{$=B(),J.debug(`Rendering info diagram
|
|
`+t);const m=B().securityLevel;let E;m==="sandbox"&&(E=nt("#i"+u));const d=m==="sandbox"?nt(E.nodes()[0].contentDocument.body):nt("body"),i=(m==="sandbox"?E.nodes()[0].contentDocument:document).getElementById(u);P=i.parentElement.offsetWidth,P===void 0&&(P=1200),$.useWidth!==void 0&&(P=$.useWidth),$.pie.useWidth!==void 0&&(P=$.pie.useWidth);const s=d.select("#"+u);bt(s,Y,P,$.pie.useMaxWidth),i.setAttribute("viewBox","0 0 "+P+" "+Y);var S=40,o=18,a=4,p=Math.min(P,Y)/2-S,h=s.append("g").attr("transform","translate("+P/2+","+Y/2+")"),w=b.db.getSections(),L=0;Object.keys(w).forEach(function(c){L+=w[c]});const n=$.themeVariables;var N=[n.pie1,n.pie2,n.pie3,n.pie4,n.pie5,n.pie6,n.pie7,n.pie8,n.pie9,n.pie10,n.pie11,n.pie12];const l=((x=$.pie)==null?void 0:x.textPosition)??.75;let[r]=kt(n.pieOuterStrokeWidth);r??(r=2);var v=xt().range(N),A=Object.entries(w).map(function(c,f){return{order:f,name:c[0],value:c[1]}}),T=Et().value(function(c){return c.value}).sort(function(c,f){return c.order-f.order}),D=T(A),W=lt().innerRadius(0).outerRadius(p),C=lt().innerRadius(p*l).outerRadius(p*l);h.append("circle").attr("cx",0).attr("cy",0).attr("r",p+r/2).attr("class","pieOuterCircle"),h.selectAll("mySlices").data(D).enter().append("path").attr("d",W).attr("fill",function(c){return v(c.data.name)}).attr("class","pieCircle"),h.selectAll("mySlices").data(D).enter().append("text").text(function(c){return(c.data.value/L*100).toFixed(0)+"%"}).attr("transform",function(c){return"translate("+C.centroid(c)+")"}).style("text-anchor","middle").attr("class","slice"),h.append("text").text(b.db.getDiagramTitle()).attr("x",0).attr("y",-(Y-50)/2).attr("class","pieTitleText");var I=h.selectAll(".legend").data(v.domain()).enter().append("g").attr("class","legend").attr("transform",function(c,f){const F=o+a,U=F*v.domain().length/2,Q=12*o,q=f*F-U;return"translate("+Q+","+q+")"});I.append("rect").attr("width",o).attr("height",o).style("fill",v).style("stroke",v),I.data(D).append("text").attr("x",o+a).attr("y",o-a).text(function(c){return b.db.getShowData()||$.showData||$.pie.showData?c.data.name+" ["+c.data.value+"]":c.data.name})}catch(m){J.error("Error while rendering info diagram"),J.error(m)}},jt={draw:Ft},ue={parser:Dt,db:Nt,renderer:jt,styles:Ct};export{ue as diagram};
|
|
//# sourceMappingURL=pieDiagram-5efcb91d-273d956c.js.map
|