Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

177
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda