I want to create a rating scale similar to one shown in image attached. But I have not been able to do the same.
I tried different packages and also css but couldnot achieve it.
If anybody could help that would be great
Circular rating scale:
I tried using react-circular-progressbar package, react-d3-speedometer but to no avail/
Here is an example of code i tried:
<div className="mt-6 flex justify-center">
<div className="w-2/5 item-center">
<CircularProgressbarWithChildren
value={80}
text="8"
strokeWidth={15}
circleRatio={0.75}
styles={
buildStyles({
rotation: 1 / 2 + 1 / 8,
strokeLinecap: 'butt',
})
}
// onClick={(val) => {
// console.log('val', val)
// }}
> <RadialSeparators
count={13}
style={{
background: '#fff',
width: '2px',
// This needs to be equal to props.strokeWidth
height: `${15}%`,
}}
/>
</CircularProgressbarWithChildren>
</div>
</div>
2
Answers
You can do this using svg. If you draw a donut chart and divide in 12 parts, remember to leave the two ends transparent to have the effect similar to the image, put number in the middle of all parts and color based on your scaling.
In the case of the marker you can create another donut chart with only one part with stroke but fill transparent and translate based of your rating.
This is a interesting chalenge
I have created this by html css and JS,
You can find code below