on-codemerge
Version:
A WYSIWYG editor for on-codemerge is a user-friendly interface that allows users to edit and view their code in real time, exactly as it will appear in the final product
3 lines (2 loc) • 2.91 kB
JavaScript
/*! on-codemerge v1.3.1 @author Pavel Kuzmin @license MIT @homepage https://s00d.github.io/on-codemerge/ @repository git+https://github.com/s00d/on-codemerge.git Copyright (c) 2026 Pavel Kuzmin - Built on 2026-07-02T13:39:17.947Z */
;Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("./BaseChartRenderer.cjs"),T=require("../utils/validation.cjs");class k extends v.BaseChartRenderer{render(e,r,s){if(!T.validateChartData(r)){this.drawNoDataMessage(e,s);return}const c=s.orientation||"vertical",M=this.getColors(s);this.drawBackground(e,s),this.drawTitle(e,s),c==="vertical"?this.drawVerticalRadar(e,r,s,M):this.drawHorizontalRadar(e,r,s,M),this.drawAxisLabels(e,s),this.drawLegend(e,r,s)}drawVerticalRadar(e,r,s,c){const{width:M,height:f}=this.getDimensions(s),i=M/2,h=f/2,o=Math.min(M,f)/3,d=r[0].data.map(t=>t.label||""),I=Math.max(...r.flatMap(t=>t.data.map(a=>a.value||0)),1);for(let t=1;t<=5;t++){const a=o*t/5;e.beginPath(),e.arc(i,h,a,0,Math.PI*2),e.strokeStyle="#e5e7eb",e.lineWidth=1,e.stroke()}d.forEach((t,a)=>{const n=a*2*Math.PI/d.length-Math.PI/2,g=i+Math.cos(n)*o,l=h+Math.sin(n)*o;e.beginPath(),e.moveTo(i,h),e.lineTo(g,l),e.strokeStyle="#e5e7eb",e.lineWidth=1,e.stroke()}),r.forEach((t,a)=>{const n=t.color||c[a%c.length];e.beginPath(),t.data.forEach((g,l)=>{const P=l*2*Math.PI/d.length-Math.PI/2,b=g.value||0,y=o*b/I,m=i+Math.cos(P)*y,u=h+Math.sin(P)*y;l===0?e.moveTo(m,u):e.lineTo(m,u)}),e.closePath(),e.fillStyle=this.colorWithOpacity(n,.2),e.fill(),e.strokeStyle=n,e.lineWidth=2,e.stroke()}),d.forEach((t,a)=>{const n=a*2*Math.PI/d.length-Math.PI/2,g=i+Math.cos(n)*(o+20),l=h+Math.sin(n)*(o+20);e.fillStyle=this.getTextColor(s),e.font="12px Inter, system-ui, sans-serif",e.textAlign="center",e.textBaseline="middle",e.fillText(t,g,l)})}drawHorizontalRadar(e,r,s,c){const{width:M,height:f}=this.getDimensions(s),i=M/2,h=f/2,o=Math.min(M,f)/3,d=r[0].data.map(t=>t.label||""),I=Math.max(...r.flatMap(t=>t.data.map(a=>a.value||0)),1);for(let t=1;t<=5;t++){const a=o*t/5;e.beginPath(),e.arc(i,h,a,0,Math.PI*2),e.strokeStyle="#e5e7eb",e.lineWidth=1,e.stroke()}d.forEach((t,a)=>{const n=a*2*Math.PI/d.length+Math.PI/2,g=i+Math.cos(n)*o,l=h+Math.sin(n)*o;e.beginPath(),e.moveTo(i,h),e.lineTo(g,l),e.strokeStyle="#e5e7eb",e.lineWidth=1,e.stroke()}),r.forEach((t,a)=>{const n=t.color||c[a%c.length];e.beginPath(),t.data.forEach((g,l)=>{const P=l*2*Math.PI/d.length+Math.PI/2,b=g.value||0,y=o*b/I,m=i+Math.cos(P)*y,u=h+Math.sin(P)*y;l===0?e.moveTo(m,u):e.lineTo(m,u)}),e.closePath(),e.fillStyle=this.colorWithOpacity(n,.2),e.fill(),e.strokeStyle=n,e.lineWidth=2,e.stroke()}),d.forEach((t,a)=>{const n=a*2*Math.PI/d.length+Math.PI/2,g=i+Math.cos(n)*(o+20),l=h+Math.sin(n)*(o+20);e.fillStyle=this.getTextColor(s),e.font="12px Inter, system-ui, sans-serif",e.textAlign="center",e.textBaseline="middle",e.fillText(t,g,l)})}}exports.RadarChartRenderer=k;