2013-10-11 14 views
18

Voglio visualizzare più serie di dati in tooltip su ogni colonnaCome ottenere più dati di serie in Highcharts tooltip?

tooltip: { 
    formatter: function() { 
     return '<span style="color:#D31B22;font-weight:bold;">' +this.series.name +': '+ this.y +'<br/>'+ 
       '<b style="color:#D31B22;font-weight:bold;">'+this.x +'</b><span>'; 
    } 
}, 

e Data

series: [{ 
    showInLegend: false, 
    name: 'Total Click', 
    data: [3000,200,50,4000], 
    color: '#9D9D9D' 
}, { 
    showInLegend: false, 
    name: 'Total View', 
    data: [100,2000,3000,4000], 
    color: '#D8D8D8' 
}] 

Sto usando come questo, ma nella descrizione comandi una sola serie di dati sta mostrando alla volta. Desidero visualizzare Dati come questo (Visualizzazione totale: 100 e Totale clic: 3000)

+0

aggiungere il codice, in modo che io posso aiutarti :) –

+0

hey, Mohit si prega di controllare il mio codice Penso che questo è quello che serve http://jsfiddle.net/pintu31/AcNUM/2/ –

+0

bel lavoro ............... Pragnesh –

risposta

29

riprova utilizzando questo codice

updated DEMO

tooltip: { 
     formatter: function() { 
      var s = []; 

      $.each(this.points, function(i, point) { 
       s.push('<span style="color:#D31B22;font-weight:bold;">'+ point.series.name +' : '+ 
        point.y +'<span>'); 
      }); 

      return s.join(' and '); 
     }, 
     shared: true 
    }, 
+0

's.push (' '' – grantiago

1

Se qualcuno cerca di dispersione, ecco solution per mostrare tooltip condivisa.

formatter: function(args) { 
    var this_point_index = this.series.data.indexOf(this.point); 
    var this_series_index = this.series.index; 
    var that_series_index = this.series.index == 0 ? 1 : 0; // assuming 2 series 
    var that_series = args.chart.series[that_series_index]; 
    var that_point = that_series.data[this_point_index]; 
    return 'Client: ' + this.point.name + 
      '<br/>Client Health: ' + this.x + 
      '<br/>' + this.series.name + ' Bandwidth: ' + this.y + 'Kbps' + 
      '<br/>' + that_series.name + ' Bandwidth: ' + that_point.y + 'Kbps'; 
} 

Jsfiddle link to Solution

+0

c'è una soluzione come questo per Sharts di colonna? – es3735746

Problemi correlati