UNPKG

ruru

Version:

Grafast-flavoured GraphiQL distribution

2 lines • 6.87 kB
export const __webpack_esm_id__=6900;export const __webpack_esm_ids__=[6900];export const __webpack_esm_modules__={26637(t,e,a){function n(t,e){t.accDescr&&e.setAccDescription?.(t.accDescr),t.accTitle&&e.setAccTitle?.(t.accTitle),t.title&&e.setDiagramTitle?.(t.title)}a.r(e),a.d(e,{populateCommonDb:()=>n}),(0,a(79456).__name)(n,"populateCommonDb")},96900(t,e,a){a.r(e),a.d(e,{diagram:()=>z});var n=a(26637),r=a(64342),i=a(70848),s=a(39989),o=a(27166),c=a(79456),l=a(73744),d={showLegend:!0,ticks:5,max:null,min:0,graticule:"circle"},g={axes:[],curves:[],options:d},m=structuredClone(g),p=s.defaultConfig_default.radar,u=(0,c.__name)(()=>(0,i.cleanAndMerge)({...p,...(0,s.getConfig)().radar}),"getConfig"),x=(0,c.__name)(()=>m.axes,"getAxes"),h=(0,c.__name)(()=>m.curves,"getCurves"),_=(0,c.__name)(()=>m.options,"getOptions"),f=(0,c.__name)(t=>{m.axes=t.map(t=>({name:t.name,label:t.label??t.name}))},"setAxes"),$=(0,c.__name)(t=>{m.curves=t.map(t=>({name:t.name,label:t.label??t.name,entries:v(t.entries)}))},"setCurves"),v=(0,c.__name)(t=>{if(null==t[0].axis)return t.map(t=>t.value);const e=x();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:x,getCurves:h,getOptions:_,setAxes:f,setCurves:$,setOptions:(0,c.__name)(t=>{const e=t.reduce((t,e)=>(t[e.name]=e,t),{});m.options={showLegend:e.showLegend?.value??d.showLegend,ticks:e.ticks?.value??d.ticks,max:e.max?.value??d.max,min:e.min?.value??d.min,graticule:e.graticule?.value??d.graticule},m.options.ticks>32&&(o.log.warn(`Radar diagram ticks (${m.options.ticks}) exceeds maximum allowed (32). Using 32 instead.`),m.options.ticks=32)},"setOptions"),getConfig:u,clear:(0,c.__name)(()=>{(0,s.clear)(),m=structuredClone(g)},"clear"),setAccTitle:s.setAccTitle,getAccTitle:s.getAccTitle,setDiagramTitle:s.setDiagramTitle,getDiagramTitle:s.getDiagramTitle,getAccDescription:s.getAccDescription,setAccDescription:s.setAccDescription},w=(0,c.__name)(t=>{(0,n.populateCommonDb)(t,y);const{axes:e,curves:a,options:r}=t;y.setAxes(e),y.setCurves(a),y.setOptions(r)},"populate"),b={parse:(0,c.__name)(async t=>{const e=await(0,l.parse)("radar",t);o.log.debug(e),w(e)},"parse")},C=(0,c.__name)((t,e,a,n)=>{const i=n.db,s=i.getAxes(),o=i.getCurves(),c=i.getOptions(),l=i.getConfig(),d=i.getDiagramTitle(),g=(0,r.selectSvgElement)(e),m=M(g,l),p=c.max??Math.max(...o.map(t=>Math.max(...t.entries))),u=c.min,x=Math.min(l.width,l.height)/2;T(m,s,x,c.ticks,c.graticule),A(m,s,x,l),k(m,s,o,u,p,c.graticule,l),O(m,o,c.showLegend,l),m.append("text").attr("class","radarTitle").text(d).attr("x",0).attr("y",-l.height/2-l.marginTop)},"draw"),M=(0,c.__name)((t,e)=>{const a=e.width+e.marginLeft+e.marginRight,n=e.height+e.marginTop+e.marginBottom,r=e.marginLeft+e.width/2,i=e.marginTop+e.height/2;return(0,s.configureSvgSize)(t,n,a,e.useMaxWidth??!0),t.attr("viewBox",`0 0 ${a} ${n}`).attr("overflow","visible"),t.append("g").attr("transform",`translate(${r}, ${i})`)},"drawFrame"),T=(0,c.__name)((t,e,a,n,r)=>{if("circle"===r)for(let e=0;e<n;e++){const r=a*(e+1)/n;t.append("circle").attr("r",r).attr("class","radarGraticule")}else if("polygon"===r){const r=e.length;for(let i=0;i<n;i++){const s=a*(i+1)/n,o=e.map((t,e)=>{const a=2*e*Math.PI/r-Math.PI/2;return`${s*Math.cos(a)},${s*Math.sin(a)}`}).join(" ");t.append("polygon").attr("points",o).attr("class","radarGraticule")}}},"drawGraticule"),A=(0,c.__name)((t,e,a,n)=>{const r=e.length;for(let i=0;i<r;i++){const s=e[i].label,o=2*i*Math.PI/r-Math.PI/2,c=Math.cos(o),l=Math.sin(o);t.append("line").attr("x1",0).attr("y1",0).attr("x2",a*n.axisScaleFactor*c).attr("y2",a*n.axisScaleFactor*l).attr("class","radarAxisLine");const d=c>.01?"start":c<-.01?"end":"middle",g=l>.01?"hanging":l<-.01?"auto":"central",m=4;t.append("text").text(s).attr("x",a*n.axisLabelFactor*c+m*c).attr("y",a*n.axisLabelFactor*l+m*l).attr("text-anchor",d).attr("dominant-baseline",g).attr("class","radarAxisLabel")}},"drawAxes");function k(t,e,a,n,r,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=L(t,n,r,c);return{x:i*Math.cos(a),y:i*Math.sin(a)}});"circle"===i?t.append("path").attr("d",D(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 L(t,e,a,n){return n*(Math.min(Math.max(t,e),a)-e)/(a-e)}function D(t,e){const a=t.length;let n=`M${t[0].x},${t[0].y}`;for(let r=0;r<a;r++){const i=t[(r-1+a)%a],s=t[r],o=t[(r+1)%a],c=t[(r+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};n+=` C${l.x},${l.y} ${d.x},${d.y} ${o.x},${o.y}`}return`${n} Z`}function O(t,e,a,n){if(!a)return;const r=3*(n.width/2+n.marginRight)/4,i=3*-(n.height/2+n.marginTop)/4;e.forEach((e,a)=>{const n=t.append("g").attr("transform",`translate(${r}, ${i+20*a})`);n.append("rect").attr("width",12).attr("height",12).attr("class",`radarLegendBox-${a}`),n.append("text").attr("x",16).attr("y",0).attr("class","radarLegendText").text(e.label)})}(0,c.__name)(k,"drawCurves"),(0,c.__name)(L,"relativeRadius"),(0,c.__name)(D,"closedRoundCurve"),(0,c.__name)(O,"drawLegend");var S={draw:C},I=(0,c.__name)((t,e)=>{let a="";for(let n=0;n<t.THEME_COLOR_LIMIT;n++){const r=t[`cScale${n}`];a+=`\n\t\t.radarCurve-${n} {\n\t\t\tcolor: ${r};\n\t\t\tfill: ${r};\n\t\t\tfill-opacity: ${e.curveOpacity};\n\t\t\tstroke: ${r};\n\t\t\tstroke-width: ${e.curveStrokeWidth};\n\t\t}\n\t\t.radarLegendBox-${n} {\n\t\t\tfill: ${r};\n\t\t\tfill-opacity: ${e.curveOpacity};\n\t\t\tstroke: ${r};\n\t\t}\n\t\t`}return a},"genIndexStyles"),E=(0,c.__name)(t=>{const e=(0,s.getThemeVariables)(),a=(0,s.getConfig)(),n=(0,i.cleanAndMerge)(e,a.themeVariables);return{themeVariables:n,radarOptions:(0,i.cleanAndMerge)(n.radar,t)}},"buildRadarStyleOptions"),z={parser:b,db:y,renderer:S,styles:(0,c.__name)(({radar:t}={})=>{const{themeVariables:e,radarOptions:a}=E(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\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${I(e,a)}\n\t`},"styles")}}}; //# sourceMappingURL=6900.js.map