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

130
Visualizações
D3 js filter select

I dont knoe exactly what is going on here tried everything to no success, here is my code, i am trying to add color by changing the opacity with the rgba, but i noticed only the first element of the selected(this) is being given the rgba and the rest turns to rgb, please note am talking about the line of that has the style('fill',`rgba(${red}, ${green}, ${blue}, ${i+1 * 0.25}`)

        currentEl.filter(function(d, i, n):any {
            if(bottonValue==='filter-odd') {
                if(i % 2 === 0) {
                    select(this).style('fill',`rgba(${red}, ${green}, ${blue}, ${i+1 * 0.25}`)
                }
                else {
                    select(this).style('fill','rgba(248, 248, 248, 0.5)')
                }
            }
            else if(bottonValue==='filter-even') {
                if(i % 2 !== 0) {
                    select(this).style('fill',`rgba(${red}, ${green}, ${blue}, ${i+1 * 0.25}`,)
                }
                else {
                    select(this).style('fill','rgba(248, 248, 248, 0.5)')
                }
            }
            else
                select(this).style('fill',`rgba(${red}, ${green}, ${blue}, ${i+1 * 0.25}`)
           
        }) 
    }```

below is my code 


[![dom and result image][1]][1]


  [1]: https://i.stack.imgur.com/BhhtW.jpg
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Well i solved with the help from discord, i needed to add (i+1) and not i+1

select(this).style('fill',`rgba(${red}, ${green}, ${blue}, ${(i+1) * 0.25}`,)
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