Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

174
Views
How to slice a circle equally based on array length of elements ? Using react/javascript html css

Trying to create a Polar/Radar Chart, I want to create separate slices of the first circle based on the length of the array items. And print each item.name in each slice equally and text style in Arc. Circle width 720px and height 720px.

When I map through the array and print names, it creates a separate circle for each name because I am mapping outside the dev.

Any ideas, solutions are appreciated. Thanks

    const items = [{ "id": 1, "name": "javascript" }, { "id": 2, "name": "HTML" }, { "id": 1, "name": "CSS" }]
    const length = items?.length ?? 0
    const width = 720
    const slice = width / length
     
    return (
            <div>
              { items?.map(item =>
              <div className={styles.circle} style={{width: `${slice}}}>
                <p>{item.name}</p>
              </div>
               )}
            </div>
    )

    //css
    .circle {
       height: 720px;
       border: solid 1px #fafafa;
       background: #fafafa;
       border-radius: 50%;
       padding: 20px;
       position: relative;
     }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can draw your pie chart using react-google-charts easily. It supports a fair amount of options to manage the chart.

import React from "react";
import { Chart } from "react-google-charts";

const data = [
  ["Language", "Popularity"],
  ["Javascript", 1],
  ["HTML", 1],
  ["CSS", 1]
];

const options = {
  legend: "none",
  pieSliceText: "label",
  title: "Language Popularity",
  pieStartAngle: 180
};

export default function App() {
  return (
    <Chart
      chartType="PieChart"
      data={data}
      options={options}
      width={"100%"}
      height={"400px"}
    />
  );
}

Edit magical-liskov-bvy4i3

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!