{"version":3,"file":"GradientAreaChart.Bkm0lr06.mjs","names":[],"sources":["https:/framerusercontent.com/modules/wPjJYFnFK8Xp4fSju2pC/zVHouNsR4YTYcOzOWkKt/GradientAreaChart.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{useMemo,useRef,useEffect,useState}from\"react\";/**\n * Gradient Area Chart\n * \n * A customizable area chart with gradient fill that displays data from Monday to Sunday.\n * \n * @framerIntrinsicWidth 400\n * @framerIntrinsicHeight 200\n * \n * @framerSupportedLayoutWidth fixed\n * @framerSupportedLayoutHeight fixed\n */export default function GradientAreaChart(props){const{data=[25,40,30,50,70,45,60],lineColor=\"#4A7DFC\",lineCount=5,showGrid=true,gridColor=\"#E0E0E0\",style}=props;const canvasRef=useRef(null);const containerRef=useRef(null);const[hoveredPoint,setHoveredPoint]=useState(null);const days=[\"MON\",\"TUE\",\"WED\",\"THU\",\"FRI\",\"SAT\",\"SUN\"];// Generate random data if not provided\nconst chartData=useMemo(()=>{if(data.length===7)return data;return Array.from({length:7},()=>Math.floor(Math.random()*80)+10);},[data]);// Find max value for scaling\nconst maxValue=useMemo(()=>{return Math.max(...chartData)*1.2;},[chartData]);// Handle mouse movement for tooltips\nconst handleMouseMove=e=>{const canvas=canvasRef.current;if(!canvas)return;const rect=canvas.getBoundingClientRect();const x=e.clientX-rect.left;const y=e.clientY-rect.top;const padding={top:20,right:20,bottom:30,left:40};const chartWidth=rect.width-padding.left-padding.right;// Create points for the line\nconst points=chartData.map((value,index)=>{const pointX=padding.left+chartWidth*index/(chartData.length-1);const pointY=padding.top+(rect.height-padding.top-padding.bottom)-(rect.height-padding.top-padding.bottom)*value/maxValue;return{x:pointX,y:pointY,value};});// Find closest point\nlet closestPoint=null;let minDistance=Number.MAX_VALUE;points.forEach(point=>{const distance=Math.sqrt(Math.pow(x-point.x,2)+Math.pow(y-point.y,2));if(distance<minDistance&&distance<30){minDistance=distance;closestPoint=point;}});setHoveredPoint(closestPoint);};const handleMouseLeave=()=>{setHoveredPoint(null);};useEffect(()=>{const canvas=canvasRef.current;if(!canvas)return;const ctx=canvas.getContext(\"2d\");if(!ctx)return;const dpr=window.devicePixelRatio||1;const rect=canvas.getBoundingClientRect();// Set canvas size accounting for device pixel ratio\ncanvas.width=rect.width*dpr;canvas.height=rect.height*dpr;ctx.scale(dpr,dpr);// Clear canvas\nctx.clearRect(0,0,rect.width,rect.height);const padding={top:20,right:20,bottom:30,left:40};const chartWidth=rect.width-padding.left-padding.right;const chartHeight=rect.height-padding.top-padding.bottom;// Set font to Poppins\nctx.font=\"11px 'Poppins', sans-serif\";// Draw grid lines\nif(showGrid){ctx.strokeStyle=gridColor;ctx.lineWidth=1;// Horizontal grid lines\nfor(let i=0;i<=lineCount;i++){const y=padding.top+chartHeight*i/lineCount;ctx.beginPath();ctx.moveTo(padding.left,y);ctx.lineTo(rect.width-padding.right,y);ctx.stroke();// Add value labels (in minutes)\nconst value=Math.round(maxValue-maxValue*i/lineCount);ctx.fillStyle=\"#888\";ctx.textAlign=\"right\";ctx.fillText(value.toString(),padding.left-5,y+3);}// Vertical grid lines (days)\nfor(let i=0;i<days.length;i++){const x=padding.left+chartWidth*i/(days.length-1);ctx.beginPath();ctx.moveTo(x,padding.top);ctx.lineTo(x,rect.height-padding.bottom);ctx.stroke();// Add day labels in all caps\nctx.fillStyle=\"#888\";ctx.textAlign=\"center\";ctx.fillText(days[i],x,rect.height-padding.bottom+15);}}// Draw area\nctx.beginPath();ctx.moveTo(padding.left,rect.height-padding.bottom);// Create points for the line\nconst points=chartData.map((value,index)=>{const x=padding.left+chartWidth*index/(chartData.length-1);const y=padding.top+chartHeight-chartHeight*value/maxValue;return{x,y};});// Draw the line and collect points\npoints.forEach((point,index)=>{if(index===0){ctx.moveTo(point.x,point.y);}else{// Create a smooth curve\nconst prevPoint=points[index-1];const cpX1=prevPoint.x+(point.x-prevPoint.x)/3;const cpX2=point.x-(point.x-prevPoint.x)/3;ctx.bezierCurveTo(cpX1,prevPoint.y,cpX2,point.y,point.x,point.y);}});// Complete the area by drawing to the bottom right and bottom left\nctx.lineTo(padding.left+chartWidth,rect.height-padding.bottom);ctx.lineTo(padding.left,rect.height-padding.bottom);ctx.closePath();// Create gradient\nconst gradient=ctx.createLinearGradient(0,padding.top,0,rect.height-padding.bottom);// Convert color to rgba format for gradient\nconst hexToRgba=(hex,alpha)=>{const r=parseInt(hex.slice(1,3),16);const g=parseInt(hex.slice(3,5),16);const b=parseInt(hex.slice(5,7),16);return`rgba(${r}, ${g}, ${b}, ${alpha})`;};const rgbToRgba=(rgb,alpha)=>{const match=rgb.match(/rgb\\((\\d+),\\s*(\\d+),\\s*(\\d+)\\)/);if(match){return`rgba(${match[1]}, ${match[2]}, ${match[3]}, ${alpha})`;}return rgb;};let topColor;let bottomColor;if(lineColor.startsWith(\"#\")){topColor=hexToRgba(lineColor,.6);bottomColor=hexToRgba(lineColor,.06);}else if(lineColor.startsWith(\"rgb(\")){topColor=rgbToRgba(lineColor,.6);bottomColor=rgbToRgba(lineColor,.06);}else{// Fallback for other color formats\ntopColor=lineColor;bottomColor=lineColor;}gradient.addColorStop(0,topColor);gradient.addColorStop(1,bottomColor);ctx.fillStyle=gradient;ctx.fill();// Draw the line on top of the area\nctx.beginPath();points.forEach((point,index)=>{if(index===0){ctx.moveTo(point.x,point.y);}else{const prevPoint=points[index-1];const cpX1=prevPoint.x+(point.x-prevPoint.x)/3;const cpX2=point.x-(point.x-prevPoint.x)/3;ctx.bezierCurveTo(cpX1,prevPoint.y,cpX2,point.y,point.x,point.y);}});ctx.strokeStyle=lineColor;ctx.lineWidth=2;ctx.stroke();// Draw points\npoints.forEach(point=>{ctx.beginPath();ctx.arc(point.x,point.y,4,0,Math.PI*2);ctx.fillStyle=\"white\";ctx.fill();ctx.strokeStyle=lineColor;ctx.lineWidth=2;ctx.stroke();});},[chartData,lineColor,lineCount,showGrid,gridColor,maxValue]);return /*#__PURE__*/_jsxs(\"div\",{ref:containerRef,style:{position:\"relative\",width:\"100%\",height:\"100%\",fontFamily:\"'Poppins', sans-serif\",...style},children:[/*#__PURE__*/_jsx(\"link\",{href:\"https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600&display=swap\",rel:\"stylesheet\"}),/*#__PURE__*/_jsx(\"canvas\",{ref:canvasRef,style:{position:\"absolute\",top:0,left:0,width:\"100%\",height:\"100%\",cursor:\"pointer\"},onMouseMove:handleMouseMove,onMouseLeave:handleMouseLeave}),hoveredPoint&&/*#__PURE__*/_jsxs(\"div\",{style:{position:\"absolute\",left:`${hoveredPoint.x}px`,top:`${hoveredPoint.y-40}px`,background:\"rgba(0,0,0,0.8)\",color:\"white\",padding:\"4px 8px\",borderRadius:\"4px\",fontSize:\"12px\",transform:\"translateX(-50%)\",pointerEvents:\"none\",zIndex:10,fontFamily:\"'Poppins', sans-serif\"},children:[hoveredPoint.value,\" min\"]})]});}addPropertyControls(GradientAreaChart,{data:{type:ControlType.Array,title:\"Data (minutes)\",control:{type:ControlType.Number,min:0,max:100,step:1},defaultValue:[25,40,30,50,70,45,60],maxCount:7},lineColor:{type:ControlType.Color,title:\"Line Color\",defaultValue:\"#4A7DFC\"},lineCount:{type:ControlType.Number,title:\"Grid Lines\",defaultValue:5,min:2,max:10,step:1},showGrid:{type:ControlType.Boolean,title:\"Show Grid\",defaultValue:true,enabledTitle:\"Show\",disabledTitle:\"Hide\"},gridColor:{type:ControlType.Color,title:\"Grid Color\",defaultValue:\"#E0E0E0\",hidden:({showGrid})=>!showGrid}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"GradientAreaChart\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerIntrinsicHeight\":\"200\",\"framerSupportedLayoutWidth\":\"fixed\",\"framerSupportedLayoutHeight\":\"fixed\",\"framerIntrinsicWidth\":\"400\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./GradientAreaCh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