ok banget
This commit is contained in:
@@ -1,17 +1,17 @@
|
||||
import React from "react";
|
||||
|
||||
const CircularDiagram = ({ segments }) => {
|
||||
const radius = 100; // Radius of the circle
|
||||
const strokeWidth = 30; // Width of each portion
|
||||
const radius = 70; // Radius of the circle
|
||||
const strokeWidth = 20; // Width of each portion
|
||||
const circumference = 2 * Math.PI * (radius - strokeWidth / 2);
|
||||
|
||||
let startOffset = 0; // Initial offset for each segment
|
||||
let startOffset = -63; // Initial offset for each segment
|
||||
|
||||
const svgStyles = {
|
||||
display: "block",
|
||||
margin: "0 auto",
|
||||
};
|
||||
|
||||
console.log(segments)
|
||||
return (
|
||||
<svg
|
||||
width={radius * 2}
|
||||
@@ -29,7 +29,10 @@ const CircularDiagram = ({ segments }) => {
|
||||
/>
|
||||
{segments.map((segment, index) => {
|
||||
const { percentage, color } = segment;
|
||||
const segmentLength = (circumference * percentage) / 100;
|
||||
console.log(percentage)
|
||||
let p = percentage;
|
||||
if(p == 'Infinity' || isNaN(p)) p = 0;
|
||||
const segmentLength = (circumference * p) / 100;
|
||||
const strokeDashoffset = circumference - startOffset;
|
||||
|
||||
startOffset += segmentLength;
|
||||
|
||||
Reference in New Issue
Block a user