UNPKG

ruru

Version:

Grafast-flavoured GraphiQL distribution

2 lines 6.27 kB
export const __webpack_id__=1931;export const __webpack_ids__=[1931];export const __webpack_modules__={23960:(t,e,a)=>{function r(t,e){t.accDescr&&e.setAccDescription?.(t.accDescr),t.accTitle&&e.setAccTitle?.(t.accTitle),t.title&&e.setDiagramTitle?.(t.title)}a.d(e,{S:()=>r}),(0,a(58084).K2)(r,"populateCommonDb")},51931:(t,e,a)=>{a.d(e,{diagram:()=>I});var r=a(23960),n=a(65323),i=a(5162),s=a(58084),o=a(73744),c={showLegend:!0,ticks:5,max:null,min:0,graticule:"circle"},l={axes:[],curves:[],options:c},d=structuredClone(l),g=s.UI.radar,p=(0,s.K2)(()=>(0,n.$t)({...g,...(0,s.zj)().radar}),"getConfig"),u=(0,s.K2)(()=>d.axes,"getAxes"),h=(0,s.K2)(()=>d.curves,"getCurves"),x=(0,s.K2)(()=>d.options,"getOptions"),m=(0,s.K2)(t=>{d.axes=t.map(t=>({name:t.name,label:t.label??t.name}))},"setAxes"),$=(0,s.K2)(t=>{d.curves=t.map(t=>({name:t.name,label:t.label??t.name,entries:f(t.entries)}))},"setCurves"),f=(0,s.K2)(t=>{if(null==t[0].axis)return t.map(t=>t.value);const e=u();if(0===e.length)throw new Error("Axes must be populated before curves for reference entries");return e.map(e=>{const a=t.find(t=>t.axis?.$refText===e.name);if(void 0===a)throw new Error("Missing entry for axis "+e.label);return a.value})},"computeCurveEntries"),y={getAxes:u,getCurves:h,getOptions:x,setAxes:m,setCurves:$,setOptions:(0,s.K2)(t=>{const e=t.reduce((t,e)=>(t[e.name]=e,t),{});d.options={showLegend:e.showLegend?.value??c.showLegend,ticks:e.ticks?.value??c.ticks,max:e.max?.value??c.max,min:e.min?.value??c.min,graticule:e.graticule?.value??c.graticule}},"setOptions"),getConfig:p,clear:(0,s.K2)(()=>{(0,s.IU)(),d=structuredClone(l)},"clear"),setAccTitle:s.SV,getAccTitle:s.iN,setDiagramTitle:s.ke,getDiagramTitle:s.ab,getAccDescription:s.m7,setAccDescription:s.EI},v=(0,s.K2)(t=>{(0,r.S)(t,y);const{axes:e,curves:a,options:n}=t;y.setAxes(e),y.setCurves(a),y.setOptions(n)},"populate"),w={parse:(0,s.K2)(async t=>{const e=await(0,o.qg)("radar",t);s.Rm.debug(e),v(e)},"parse")},b=(0,s.K2)((t,e,a,r)=>{const n=r.db,s=n.getAxes(),o=n.getCurves(),c=n.getOptions(),l=n.getConfig(),d=n.getDiagramTitle(),g=(0,i.D)(e),p=C(g,l),u=c.max??Math.max(...o.map(t=>Math.max(...t.entries))),h=c.min,x=Math.min(l.width,l.height)/2;M(p,s,x,c.ticks,c.graticule),K(p,s,x,l),L(p,s,o,h,u,c.graticule,l),A(p,o,c.showLegend,l),p.append("text").attr("class","radarTitle").text(d).attr("x",0).attr("y",-l.height/2-l.marginTop)},"draw"),C=(0,s.K2)((t,e)=>{const a=e.width+e.marginLeft+e.marginRight,r=e.height+e.marginTop+e.marginBottom,n=e.marginLeft+e.width/2,i=e.marginTop+e.height/2;return t.attr("viewbox",`0 0 ${a} ${r}`).attr("width",a).attr("height",r),t.append("g").attr("transform",`translate(${n}, ${i})`)},"drawFrame"),M=(0,s.K2)((t,e,a,r,n)=>{if("circle"===n)for(let e=0;e<r;e++){const n=a*(e+1)/r;t.append("circle").attr("r",n).attr("class","radarGraticule")}else if("polygon"===n){const n=e.length;for(let i=0;i<r;i++){const s=a*(i+1)/r,o=e.map((t,e)=>{const a=2*e*Math.PI/n-Math.PI/2;return`${s*Math.cos(a)},${s*Math.sin(a)}`}).join(" ");t.append("polygon").attr("points",o).attr("class","radarGraticule")}}},"drawGraticule"),K=(0,s.K2)((t,e,a,r)=>{const n=e.length;for(let i=0;i<n;i++){const s=e[i].label,o=2*i*Math.PI/n-Math.PI/2;t.append("line").attr("x1",0).attr("y1",0).attr("x2",a*r.axisScaleFactor*Math.cos(o)).attr("y2",a*r.axisScaleFactor*Math.sin(o)).attr("class","radarAxisLine"),t.append("text").text(s).attr("x",a*r.axisLabelFactor*Math.cos(o)).attr("y",a*r.axisLabelFactor*Math.sin(o)).attr("class","radarAxisLabel")}},"drawAxes");function L(t,e,a,r,n,i,s){const o=e.length,c=Math.min(s.width,s.height)/2;a.forEach((e,a)=>{if(e.entries.length!==o)return;const l=e.entries.map((t,e)=>{const a=2*Math.PI*e/o-Math.PI/2,i=T(t,r,n,c);return{x:i*Math.cos(a),y:i*Math.sin(a)}});"circle"===i?t.append("path").attr("d",k(l,s.curveTension)).attr("class",`radarCurve-${a}`):"polygon"===i&&t.append("polygon").attr("points",l.map(t=>`${t.x},${t.y}`).join(" ")).attr("class",`radarCurve-${a}`)})}function T(t,e,a,r){return r*(Math.min(Math.max(t,e),a)-e)/(a-e)}function k(t,e){const a=t.length;let r=`M${t[0].x},${t[0].y}`;for(let n=0;n<a;n++){const i=t[(n-1+a)%a],s=t[n],o=t[(n+1)%a],c=t[(n+2)%a],l={x:s.x+(o.x-i.x)*e,y:s.y+(o.y-i.y)*e},d={x:o.x-(c.x-s.x)*e,y:o.y-(c.y-s.y)*e};r+=` C${l.x},${l.y} ${d.x},${d.y} ${o.x},${o.y}`}return`${r} Z`}function A(t,e,a,r){if(!a)return;const n=3*(r.width/2+r.marginRight)/4,i=3*-(r.height/2+r.marginTop)/4;e.forEach((e,a)=>{const r=t.append("g").attr("transform",`translate(${n}, ${i+20*a})`);r.append("rect").attr("width",12).attr("height",12).attr("class",`radarLegendBox-${a}`),r.append("text").attr("x",16).attr("y",0).attr("class","radarLegendText").text(e.label)})}(0,s.K2)(L,"drawCurves"),(0,s.K2)(T,"relativeRadius"),(0,s.K2)(k,"closedRoundCurve"),(0,s.K2)(A,"drawLegend");var _={draw:b},O=(0,s.K2)((t,e)=>{let a="";for(let r=0;r<t.THEME_COLOR_LIMIT;r++){const n=t[`cScale${r}`];a+=`\n\t\t.radarCurve-${r} {\n\t\t\tcolor: ${n};\n\t\t\tfill: ${n};\n\t\t\tfill-opacity: ${e.curveOpacity};\n\t\t\tstroke: ${n};\n\t\t\tstroke-width: ${e.curveStrokeWidth};\n\t\t}\n\t\t.radarLegendBox-${r} {\n\t\t\tfill: ${n};\n\t\t\tfill-opacity: ${e.curveOpacity};\n\t\t\tstroke: ${n};\n\t\t}\n\t\t`}return a},"genIndexStyles"),S=(0,s.K2)(t=>{const e=(0,s.P$)(),a=(0,s.zj)(),r=(0,n.$t)(e,a.themeVariables);return{themeVariables:r,radarOptions:(0,n.$t)(r.radar,t)}},"buildRadarStyleOptions"),I={parser:w,db:y,renderer:_,styles:(0,s.K2)(({radar:t}={})=>{const{themeVariables:e,radarOptions:a}=S(t);return`\n\t.radarTitle {\n\t\tfont-size: ${e.fontSize};\n\t\tcolor: ${e.titleColor};\n\t\tdominant-baseline: hanging;\n\t\ttext-anchor: middle;\n\t}\n\t.radarAxisLine {\n\t\tstroke: ${a.axisColor};\n\t\tstroke-width: ${a.axisStrokeWidth};\n\t}\n\t.radarAxisLabel {\n\t\tdominant-baseline: middle;\n\t\ttext-anchor: middle;\n\t\tfont-size: ${a.axisLabelFontSize}px;\n\t\tcolor: ${a.axisColor};\n\t}\n\t.radarGraticule {\n\t\tfill: ${a.graticuleColor};\n\t\tfill-opacity: ${a.graticuleOpacity};\n\t\tstroke: ${a.graticuleColor};\n\t\tstroke-width: ${a.graticuleStrokeWidth};\n\t}\n\t.radarLegendText {\n\t\ttext-anchor: start;\n\t\tfont-size: ${a.legendFontSize}px;\n\t\tdominant-baseline: hanging;\n\t}\n\t${O(e,a)}\n\t`},"styles")}}}; //# sourceMappingURL=1931.js.map