question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to set the percent of each RadialBar in RadialBarChart?

See original GitHub issue

Do you want to request a feature or report a bug?

feature

What is the current behavior?

The code as below:

import  {ResponsiveContainer, RadialBar,RadialBarChart,Legend} from 'recharts';
const data = [
    { uv: 100, fill: '#ffff00' },
    { uv: 20, fill: '#83a6ed' },
    { uv: 30, fill: '#83a6ed' },
];
const SimpleRadialBarChart = () => {
        return (
                <ResponsiveContainer width={200} height={200}>
                <RadialBarChart className="radial" cx="50%" cy="50%" innerRadius='20%' outerRadius="80%" data={data}>
                    <RadialBar minAngle={15}  background clockWise={true} dataKey='uv'/>
                </RadialBarChart>
                </ResponsiveContainer>
        );
    };

export default SimpleRadialBarChart; result is as 2017-12-19 11 59 43

What is the expected behavior?

how to set the percent of each RadialBar. If I want to set the percent of the yellow circle ,what can i do ?

2017-12-19 12 04 19

Which versions of Recharts, and which browser / OS are affected by this issue? Did this work in previous versions of Recharts?

“recharts”: “^1.0.0-beta.6”

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:21

github_iconTop GitHub Comments

24reactions
jefferymillscommented, Dec 28, 2017

@Pimaweichai In case you haven’t discovered yet here is how this can be done:

const data = [
    { uv: 100, fill: '#ffff00' },
    { uv: 20, fill: '#83a6ed' },
    { uv: 30, fill: '#83a6ed' },
];
<RadialBarChart width={200} height={200} data={data}>
    <PolarAngleAxis type="number" domain={[0, 300]} angleAxisId={0} tick={false} />
    <PolarAngleAxis type="number" domain={[0, 200]} angleAxisId={1} tick={false} />
    <PolarAngleAxis type="number" domain={[0, 100]} angleAxisId={2} tick={false} />
    <RadialBar background dataKey="uv" angleAxisId={0} data={[data[0]]} />
    <RadialBar background dataKey="uv" angleAxisId={1} data={[data[1]]} />
    <RadialBar background dataKey="uv" angleAxisId={2} data={[data[2]]} />
</RadialBarChart>
18reactions
svarlamovcommented, Jul 20, 2018

Adding on to @jefferymills for folks with n potential bars, that you can just pass the entire data array to the RadialBar as usual too. Solution looks like this:

const data = [
    { pct: 80, fill: '#ffff00' },
    { pct: 50, fill: '#ffff00' },
    { pct: 70, fill: '#ffff00' },
];
<RadialBarChart width={200} height={200} data={data}>
    <PolarAngleAxis type="number" domain={[0, 100]} dataKey={'pct'} angleAxisId={0} tick={false} />
    <RadialBar background dataKey="pct" angleAxisId={0} data={data} />
</RadialBarChart>
Read more comments on GitHub >

github_iconTop Results From Across the Web

RadialBar / Circular Gauge Chart Guide & Documentation
Radial Bar Charts or Circular Gauges are mostly used in single unit data to indicate progress/activity. It indicates values in terms of percentage....
Read more >
Radial bar chart in tableau - YouTube
How to create a Radial Bar chart in tableau using Data densification technique. Also known as Radial Pie Gauge ChartData Densification ...
Read more >
How to Create a Radial Bar Chart and Re-use as ... - YouTube
Want to learn how to design a salary structure? Check: https://salarycourse.caripros.com/thecourseFREE template for my video: Excel for HR ...
Read more >
Tableau Tutorial 67: Radial Bar Chart Using Table Calculation
This video is going to talk about how to create radial bar chart in Tableau. The challenge here is to design the radial...
Read more >
Creating Radial Bar as Easy as 1-2-3 - YouTube
Creating Radial Bar as Easy as 1-2-3 ... How to create ' Radial Bar Chart ' in Adobe Illustrator | DesignMentor (Adobe Illustrator...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found