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

180
Visualizações
AngularJS D3JS Donut chart colour change of arc on hover

I am creating donut using d3.js with AngularJS. Here is my Donut, by default I need to have same color for all the arcs of Donut chart, which is working fine. Now on hover of the particular arc I need to change the color of that particular arc to blue, which is not working. Can any one help me in this?

Below is the answer from the refernce plunker provided. :

 scope.mouseOverPath = function(d) {

          d3.select(this)
            .transition()
            .duration(duration)
            .style("fill", "blue")
            .each("start", function(d) {
              labelRadius = radius + chartConfig.labelPaddingOver;
              d3.select(this.parentNode).select('.legend')
                .transition()
                .attr("transform", function(d) {
                  var c = arc.centroid(d),
                    x = c[0],
                    y = c[1],
                    height = Math.sqrt(x * x + y * y);
                  return "translate(" + (x / height * labelRadius) + ',' +
                    (y / height * labelRadius) + ")";
                });
            })

... }

scope.mouseOutPath = function(d) {

          d3.select(this)
            .transition()
            .style('fill', function(d) {
              return color(d.data.label);
            })
            .each("start", function(d) {

              labelRadius = radius + chartConfig.labelPadding;


              d3.select(this.parentNode).select('.legend')
                .transition()
                .attr("transform", function(d) {
                  var c = arc.centroid(d),
                    x = c[0],
                    y = c[1],
                    height = Math.sqrt(x * x + y * y);
                  return "translate(" + (x / height * labelRadius) + ',' +
                    (y / height * labelRadius) + ")";
                });

 
           })
...
}
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Using d3's style method inside your directive's scope.mouseOverPath and scope.mouseOutPath methods did the trick.

https://plnkr.co/edit/P98rPVKOHOgN5fKB

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