2013-04-26 11 views

Odpowiedz

1

Nie jestem pewien, co tak bardzo się starało, ale przykład w here jest całkiem prosty.

.showValues(true) prawie wszystko.

Mam nadzieję, że to pomaga.

+0

dzięki bro .. ale byłem próbuje to zrobić na wielu wykresach słupkowych .. teraz zredagowałem pytanie, aby o tym wyraźnie wspomnieć. – azi

+0

@azi - czy próbowałeś również dodać tę linię do wykresu wielopunktowego? co zrobiłeś do tej pory? – shabeer90

+0

Tak, próbowałem tego .. nie działa ... Mam wiele wykresów słupkowych pracujących nad produkcją .. chciałem tylko wyświetlić wartości na górze ... nie znalazłem żadnego odniesienia nigdzie ... więc przystań "Próbowałem niczego (poza tym, co sugerowałeś) – azi

4

Duplikat How to display values in Stacked Multi-bar chart - nvd3 Graphs

Jest fix można wdrożyć u siebie w https://gist.github.com/topicus/217444acb4204f364e46

EDIT: skopiował kod jeśli link github zostanie usunięty:

// You need to apply this once all the animations are already finished. Otherwise labels will be placed wrongly. 

d3.selectAll('.nv-multibar .nv-group').each(function(group){ 
    var g = d3.select(this); 

    // Remove previous labels if there is any 
    g.selectAll('text').remove(); 
    g.selectAll('.nv-bar').each(function(bar){ 
    var b = d3.select(this); 
    var barWidth = b.attr('width'); 
    var barHeight = b.attr('height'); 

    g.append('text') 
     // Transforms shift the origin point then the x and y of the bar 
     // is altered by this transform. In order to align the labels 
     // we need to apply this transform to those. 
     .attr('transform', b.attr('transform')) 
     .text(function(){ 
     // Two decimals format 
     return parseFloat(bar.y).toFixed(2); 
     }) 
     .attr('y', function(){ 
     // Center label vertically 
     var height = this.getBBox().height; 
     return parseFloat(b.attr('y')) - 10; // 10 is the label's magin from the bar 
     }) 
     .attr('x', function(){ 
     // Center label horizontally 
     var width = this.getBBox().width; 
     return parseFloat(b.attr('x')) + (parseFloat(barWidth)/2) - (width/2); 
     }) 
     .attr('class', 'bar-values'); 
    }); 
}); 
Powiązane problemy