Home Forums Chart Support Tooltip formatting Reply To: Tooltip formatting

#19856

@papito,

Just like formatting the axis labels can be achieved using labelFormatter as shown in this example, you can also format toolTip content using contentFormatter according to your requirements as shown in the below code snippet –

toolTip: {			
  contentFormatter: contentFormatter
},
function contentFormatter(e){
  var hashrate = e.entries[0].dataPoint.x;
  if (hashrate < 1000000) {    
    return (Math.round(hashrate / 1000) / 1000 ).toFixed(2)+' Sol/s';
  }
  var byteUnits = [ ' Sol/s', ' KSol/s', ' MSol/s', ' GSol/s', ' TSol/s', ' PSol/s' ];
  var i = Math.floor((Math.log(hashrate/1000) / Math.log(1000)) - 1);
  hashrate = (hashrate/1000) / Math.pow(1000, i + 1);
  
  return hashrate.toFixed(2) + byteUnits[i];
}

Please take a look at this JSFiddle for a working example.

Custom ToolTip formatting

___________
Indranil Deo
Team CanvasJS