-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCircleChart.js
48 lines (46 loc) · 1.25 KB
/
CircleChart.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import React, { useState, useEffect } from "react";
import "./CircleChart.css";
export const CircleChart = ({
colors = [
"rgb(252,69,73)",
"rgb(44,201,252)",
"blue",
"orange",
"lighthreen",
"green",
"purple",
"lightblue",
],
fillLevel = "50",
text="$4500",
}) => {
const style = {
"--fillValue": `${fillLevel}`,
};
return (
<div className="circle-svg">
<svg viewBox="-4 -4 46 46">
<path
stroke="lightgray"
strokeWidth="2.8"
strokeOpacity="1"
fill="none"
strokeDasharray={`100, 100`}
d="M18 2.0845 a 15.9155 15.9155 0 0 1 0 31.831 a 15.9155 15.9155 0 0 1 0 -31.831"
></path>
<path
className="path-fill"
style={style}
stroke="rgb(26,197,167)"
strokeWidth="1.8"
strokeOpacity="1"
fill="none"
strokeLinecap="round"
strokeDasharray={`${fillLevel}, 100`}
d="M18 2.0845 a 15.9155 15.9155 0 0 1 0 31.831 a 15.9155 15.9155 0 0 1 0 -31.831"
></path>
<text text-anchor="middle" style={{fontSize:"8px",textAlign:"center"}} x="42%" y="45%">{text}</text>
</svg>
</div>
);
};