ruru
Version:
Grafast-flavoured GraphiQL distribution
2 lines • 6.6 kB
JavaScript
export const __webpack_esm_id__=1803;export const __webpack_esm_ids__=[1803];export const __webpack_esm_modules__={15348(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.r(e),a.d(e,{populateCommonDb:()=>r}),(0,a(60162).__name)(r,"populateCommonDb")},31803(t,e,a){a.r(e),a.d(e,{diagram:()=>E});var r=a(92329),n=a(15348),i=a(82029),s=a(54141),o=a(60162),l=a(73744),c={showLegend:!0,ticks:5,max:null,min:0,graticule:"circle"},d={axes:[],curves:[],options:c},g=structuredClone(d),m=s.defaultConfig_default.radar,p=(0,o.__name)(()=>(0,i.cleanAndMerge)({...m,...(0,s.getConfig)().radar}),"getConfig"),u=(0,o.__name)(()=>g.axes,"getAxes"),h=(0,o.__name)(()=>g.curves,"getCurves"),x=(0,o.__name)(()=>g.options,"getOptions"),_=(0,o.__name)(t=>{g.axes=t.map(t=>({name:t.name,label:t.label??t.name}))},"setAxes"),f=(0,o.__name)(t=>{g.curves=t.map(t=>({name:t.name,label:t.label??t.name,entries:$(t.entries)}))},"setCurves"),$=(0,o.__name)(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:_,setCurves:f,setOptions:(0,o.__name)(t=>{const e=t.reduce((t,e)=>(t[e.name]=e,t),{});g.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,o.__name)(()=>{(0,s.clear)(),g=structuredClone(d)},"clear"),setAccTitle:s.setAccTitle,getAccTitle:s.getAccTitle,setDiagramTitle:s.setDiagramTitle,getDiagramTitle:s.getDiagramTitle,getAccDescription:s.getAccDescription,setAccDescription:s.setAccDescription},v=(0,o.__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,o.__name)(async t=>{const e=await(0,l.parse)("radar",t);o.log.debug(e),v(e)},"parse")},w=(0,o.__name)((t,e,a,n)=>{const i=n.db,s=i.getAxes(),o=i.getCurves(),l=i.getOptions(),c=i.getConfig(),d=i.getDiagramTitle(),g=(0,r.selectSvgElement)(e),m=C(g,c),p=l.max??Math.max(...o.map(t=>Math.max(...t.entries))),u=l.min,h=Math.min(c.width,c.height)/2;M(m,s,h,l.ticks,l.graticule),T(m,s,h,c),A(m,s,o,u,p,l.graticule,c),D(m,o,l.showLegend,c),m.append("text").attr("class","radarTitle").text(d).attr("x",0).attr("y",-c.height/2-c.marginTop)},"draw"),C=(0,o.__name)((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,o.__name)((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"),T=(0,o.__name)((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 A(t,e,a,r,n,i,s){const o=e.length,l=Math.min(s.width,s.height)/2;a.forEach((e,a)=>{if(e.entries.length!==o)return;const c=e.entries.map((t,e)=>{const a=2*Math.PI*e/o-Math.PI/2,i=L(t,r,n,l);return{x:i*Math.cos(a),y:i*Math.sin(a)}});"circle"===i?t.append("path").attr("d",k(c,s.curveTension)).attr("class",`radarCurve-${a}`):"polygon"===i&&t.append("polygon").attr("points",c.map(t=>`${t.x},${t.y}`).join(" ")).attr("class",`radarCurve-${a}`)})}function L(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],l=t[(n+2)%a],c={x:s.x+(o.x-i.x)*e,y:s.y+(o.y-i.y)*e},d={x:o.x-(l.x-s.x)*e,y:o.y-(l.y-s.y)*e};r+=` C${c.x},${c.y} ${d.x},${d.y} ${o.x},${o.y}`}return`${r} Z`}function D(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,o.__name)(A,"drawCurves"),(0,o.__name)(L,"relativeRadius"),(0,o.__name)(k,"closedRoundCurve"),(0,o.__name)(D,"drawLegend");var O={draw:w},S=(0,o.__name)((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"),I=(0,o.__name)(t=>{const e=(0,s.getThemeVariables)(),a=(0,s.getConfig)(),r=(0,i.cleanAndMerge)(e,a.themeVariables);return{themeVariables:r,radarOptions:(0,i.cleanAndMerge)(r.radar,t)}},"buildRadarStyleOptions"),E={parser:b,db:y,renderer:O,styles:(0,o.__name)(({radar:t}={})=>{const{themeVariables:e,radarOptions:a}=I(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${S(e,a)}\n\t`},"styles")}}};
//# sourceMappingURL=1803.js.map