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

174
Visualizações
D3.js generate a color proportional to the values of a key

I have a Tree data structure where each non-leaf node (children) have this object:

    mime_types={
  "application/octet-stream": 1,
  "application/x-executable": 49,
  "application/x-object": 13,
  "application/x-sharedlib": 47,
  "image/gif": 5,
  "image/png": 3,
  "inode/symlink": 4,
  "text/plain": 58
}

Each leaf of my tree have a single type and its relative color (for example, a text/plain leaf will be colored blue). I implemented it doing:

var ListMimes = ['text/plain', 'application/x-executable', 'application/x-sharedlib', 'application/x-object', 'image/gif', 'inode/symlink', 'image/png', 'application/octet-stream']

var myColor = d3.scaleOrdinal().domain(ListMimes).range(d3.schemeSet3);

But for each non-leaf node, i want to color it (i'm drawing a sunburst) in a "proportional" way. I try to explain better: In this example i have text/plain with value 58, so this will "weight" much more than application/octet-stream in the result of the final color. So if text/plain is blue, and application/octet-stream is green, the final color will be blue with a very very little quantity of green

How can i do it using d3?

about 4 years ago · Juan Pablo Isaza
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